Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Logout Problem in .net 2.0

Logout Problem in .net 2.0

Scheduled Pinned Locked Moved ASP.NET
csharphelp
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M_Menon
    wrote on last edited by
    #1

    Hi Friends, I have a simple web applicaiton in .net 2.0 i am writing in c#. Now i am facing the problem in Logout is that, Once i click Logout it takes me back to my Login Page. But in case if i use Back Button from Browser it goes inside the last page i was. I clear all the cookies and all required things to be done on Logout. But about this Back Button. I dont know. I have searched alot for this but i really didnt find any proper solution to it. Any help regarding this will be appreciated. Thanks

    Cheers Menon

    S V 2 Replies Last reply
    0
    • M M_Menon

      Hi Friends, I have a simple web applicaiton in .net 2.0 i am writing in c#. Now i am facing the problem in Logout is that, Once i click Logout it takes me back to my Login Page. But in case if i use Back Button from Browser it goes inside the last page i was. I clear all the cookies and all required things to be done on Logout. But about this Back Button. I dont know. I have searched alot for this but i really didnt find any proper solution to it. Any help regarding this will be appreciated. Thanks

      Cheers Menon

      S Offline
      S Offline
      SomeGuyThatIsMe
      wrote on last edited by
      #2

      If you use the Session object you can call Session.Abandon() which will clear it then just put checks in the Page_Load of each page that checks if the Session is null and if so redirects them to the login page.

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      M 1 Reply Last reply
      0
      • M M_Menon

        Hi Friends, I have a simple web applicaiton in .net 2.0 i am writing in c#. Now i am facing the problem in Logout is that, Once i click Logout it takes me back to my Login Page. But in case if i use Back Button from Browser it goes inside the last page i was. I clear all the cookies and all required things to be done on Logout. But about this Back Button. I dont know. I have searched alot for this but i really didnt find any proper solution to it. Any help regarding this will be appreciated. Thanks

        Cheers Menon

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        M_Menon wrote:

        Now i am facing the problem in Logout is that, Once i click Logout it takes me back to my Login Page.

        This is because your page is cached in the user's machine. When you hit back it normally loads from the temporary internet files where normally the files will download. To overcome this problem you need to set cacheability to your pages. Try any of this code which remove the cacheability of your web page,

        Response.Cache.SetCacheability(HttpCacheability.Server);
        

        or

        Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
        

        or

        Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
        

        Venkatesh Mookkan My: Website | Yahoo Group | Blog Spot

        M 1 Reply Last reply
        0
        • S SomeGuyThatIsMe

          If you use the Session object you can call Session.Abandon() which will clear it then just put checks in the Page_Load of each page that checks if the Session is null and if so redirects them to the login page.

          Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

          M Offline
          M Offline
          M_Menon
          wrote on last edited by
          #4

          Hi there, When you Click the Back Button, it doesnt call the Page_Load method. So even if your Session is Abandon, the page will be visible. Yes But after that he wont be able to do any other function since it will go to the Page_Load Method. But the Page is still visible which is what i dont want. Thanks,

          Cheers Menon

          1 Reply Last reply
          0
          • V Venkatesh Mookkan

            M_Menon wrote:

            Now i am facing the problem in Logout is that, Once i click Logout it takes me back to my Login Page.

            This is because your page is cached in the user's machine. When you hit back it normally loads from the temporary internet files where normally the files will download. To overcome this problem you need to set cacheability to your pages. Try any of this code which remove the cacheability of your web page,

            Response.Cache.SetCacheability(HttpCacheability.Server);
            

            or

            Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            

            or

            Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
            

            Venkatesh Mookkan My: Website | Yahoo Group | Blog Spot

            M Offline
            M Offline
            M_Menon
            wrote on last edited by
            #5

            Hi Venkatesh, Thanks for the reply, I have tired almost everything to stop by using cookie and all other things possible. But nothing worked. I added your code but still nothing worked. I am putting my Logout Click Method Code here ******************************** HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-30); Response.Cookies.Add(aCookie); } Response.Buffer = true; Response.Expires = 0; Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); Response.CacheControl = "no-cache"; Response.Cache.SetCacheability(HttpCacheability.Server); FormsAuthentication.SignOut(); FormsAuthentication.RedirectToLoginPage("../Login.aspx"); Please have a look and let me know if there is anything i should add anything else :) Thanks

            Cheers Menon

            V 1 Reply Last reply
            0
            • M M_Menon

              Hi Venkatesh, Thanks for the reply, I have tired almost everything to stop by using cookie and all other things possible. But nothing worked. I added your code but still nothing worked. I am putting my Logout Click Method Code here ******************************** HttpCookie aCookie; string cookieName; int limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = Request.Cookies[i].Name; aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-30); Response.Cookies.Add(aCookie); } Response.Buffer = true; Response.Expires = 0; Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); Response.CacheControl = "no-cache"; Response.Cache.SetCacheability(HttpCacheability.Server); FormsAuthentication.SignOut(); FormsAuthentication.RedirectToLoginPage("../Login.aspx"); Please have a look and let me know if there is anything i should add anything else :) Thanks

              Cheers Menon

              V Offline
              V Offline
              Venkatesh Mookkan
              wrote on last edited by
              #6

              You have to add my code on the Page Load event.

              Venkatesh Mookkan My: Website | Yahoo Group | Blog Spot

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups