Login of different user after Logout

M

Michael Groeger

Hi,

I have implemented a simple page for FormsAuthentication and when user data
is accepted I redirect the user using
FormsAuthentication.RedirectFromLoginPage().

private void btnLogin_Click(object sender, System.EventArgs e)
{
// [...]
FormsAuthentication.RedirectFromLoginPage(username, false);
}

The application the user enters has a logout button, which calls
Session.Abandon() and FormsAuthentication.SignOut() when clicked and then
redirects the user to the main page of the application, which causes the
login page to show up again.

private Page_Load(object sender, System.EventArgs e)
{
Session.Abandon();
FormsAuthentication.SignOut();
Response.Redirect("main.aspx");
}

So far so good, when I now enter the application with the same user again,
everything works fine, but when I try to login another user, I always get
back to the login page. I also tried to do login by hand, but with the same
effect:

private void btnLogin_Click(object sender, System.EventArgs e)
{
// [...]
FormsAuthentication.SetAuthCookie(username, false);
string url = FormsAuthentication.GetRedirectUrl(username, false);
Response.Redirect(url);
}

So what am I doing wrong here?

Regards,
Michael
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top