redirection with form authentication

G

graphicsxp

Hi,
I'm using FormsAuthentication.redirectFromLoginPage() in order to to
user authentication.
The problem is that I'm redirected to the last page visited before the
session expired (or the default page if I log on for the first time).
how can I force the redirection to the default page each time I use
this method?

thanks
 
R

Remy

To redirect a user to a different page after login, you can just set
the cookie with SetAuthCookie() and then use a normal redirect.
The code below checks if user has a destination page, otherwise it will
redirect him to Home.aspx.

//check if the Redirect Page is set, if not default.aspx is assumed and
that means we wanna redirect
//to the SharedOffice page
if(FormsAuthentication.GetRedirectUrl(tbxEmailLogin.Text,
cbxRememberMe.Checked).IndexOf("default.aspx") != -1)
{
//internal user page
FormsAuthentication.SetAuthCookie(tbxEmailLogin.Text,
cbxRememberMe.Checked);
Response.Redirect("Home.aspx");
}
else
{
//just go to whatever page the user initially wanted
FormsAuthentication.RedirectFromLoginPage(tbxEmailLogin.Text,
cbxRememberMe.Checked);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top