Problems to logout without a loginstatus in vs2008

Last post 07-05-2009 8:18 AM by ClaCS. 2 replies.

Sort Posts:

  • Problems to logout without a loginstatus in vs2008

    07-03-2009, 1:11 PM
    • Member
      point Member
    • ClaCS
    • Member since 07-03-2009, 1:05 PM
    • Posts 11

    hi! Wink

    I have a little project with forms authentication

    web.config
    --------------
    <authentication mode="Forms">
          <forms defaultUrl="~/Login.aspx" loginUrl="~/Login.aspx" />
        </authentication>

    I have 2 roles ('admin' and 'user') and, for the moment, 3 pages

    Login.aspx (with a login control)
    admin/adminPage.aspx
    user/userPage.aspx


    admin web.config
    ----------------------
     <authorization>
                <allow roles="admin" />
                <deny users="*" />
            </authorization>


    user web.config
    ---------------
     <authorization>
                <allow roles="user" />
                <deny users="*" />
            </authorization>


    the adminPage.aspx and userPage.aspx have a masterpage

    The login process is correct, the 'admins' enter to admin's pages and the 'users' enter to user's page

    The masterpage has a button (ID=btnLogout) and a loginName control I try logout dynamically with this button but I can't

    I try with differents codes on the btnLogout_click

    FormsAuthentication.SignOut()
    Context.User = Nothing
    Session.Abandon()
    Session.Clear()

    and FormsAuthentication.RedirectToLoginPage

    When I press the button the browser shows me the Login page :) but When I press the back button (on the browser)
    it shows me the last visited page (admin/adminPage.aspx if the last user was an 'admin' and user/userPage.aspx if the last user was an 'user')
    It seems the logout process didn't close the session totally (or correctly)

    so... How Can I do logout dynamically?? ...I need do it without a LoginStatus


    sorry for my english :)


    Regards

  • Re: Problems to logout without a loginstatus in vs2008

    07-04-2009, 3:30 AM
    Answer
    • Contributor
      2,367 point Contributor
    • akhhttar
    • Member since 02-14-2007, 8:17 AM
    • Pakistan - Lahore
    • Posts 352

    Hi,

    In master page you need to have following code to disable Back button fuctionality by disabling client side content caching,

    Response.Buffer = True
    Response.Cache.SetCacheability(HttpCacheability.NoCache)
    Response.ExpiresAbsolute = DateTime.Now().AddDays(-1)
    Response.Expires = -1500
    Response.CacheControl = "no-cache"


    Thanks

    Muhammad Akhtar Shiekh

    Lets resolve the problem together.

    Please remember to mark the appropriate replies as answer after your question is solved, thanks

    My Blog
  • Re: Problems to logout without a loginstatus in vs2008

    07-05-2009, 8:18 AM
    • Member
      point Member
    • ClaCS
    • Member since 07-03-2009, 1:05 PM
    • Posts 11

    Thanks. I'll try with that code

Page 1 of 1 (3 items)