Problem using login control when site has both authenticated an unauthenticated users

K

Keithb

I am using the login control on my web site, which has both authenticated an
unauthenticated users. I added a logout page that is supposed to allow an
authenticated user to drop his authentication and resume operation as an
unauthenticated user. Using the below code in my logout page, the user is
taken directly to the login page immediately after logging out and has no
way of returning to the home page as an unauthenticated user.

protected void LinkButton1_Click(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
}

As a workaround, I changed the web.config file to show the loginUrl as
Default.aspx instead of login_page.aspx, as shown below:

<forms name="Enterprise Integration Interfaces : Login"
loginUrl="Default.aspx" path="/" protection="All" timeout="60"></forms>

I also added FormsAuthentication.RedirectToLoginPage(); to the linkbutton
event hander on the logout page as shown below:

protected void LinkButton1_Click(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
}

The workaround does solve the problem, however, it seems like a Kludge to
me, and I have the feeling that there is a 'proper' way to do this.

Can someone suggest a more elegant solution?

Thanks,

Keith
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top