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

Discussion in 'ASP .Net' started by Keithb, Oct 28, 2006.

  1. Keithb

    Keithb Guest

    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
    Keithb, Oct 28, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SamIAm
    Replies:
    1
    Views:
    456
    Ed Gibbs
    Dec 4, 2003
  2. =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=

    redirect unauthenticated users from frameset child pages?

    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=, Nov 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,005
    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=
    Nov 2, 2005
  3. Klaus Jensen
    Replies:
    1
    Views:
    389
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Jun 19, 2008
  4. Sandy
    Replies:
    7
    Views:
    148
    Paul Glavich [MVP ASP.NET]
    Jan 15, 2005
  5. Abhijit
    Replies:
    0
    Views:
    141
    Abhijit
    Apr 12, 2004
Loading...

Share This Page