Disabling back/forward buttons of Browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raam
    New Member
    • Jun 2008
    • 11

    Disabling back/forward buttons of Browser

    hi,

    I have an applciation where when i click on "Logout" should disable back button of browser.The page redirects to defaultlogin screen.There the buttons should get disabled.
    Can any one expalin me the procedure.

    Thanks & Regards,
    Raam.
  • readnlearn
    New Member
    • Aug 2008
    • 15

    #2
    hi,

    Code:
    Protected void Page_Init(object Sender, EventArgs e)
    {
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
    }
    this is enough to remove the bwoser cache in asp.net( with Help of c#.net)


    and also try this one

    Code:
    <%
    Response.Buffer = true;
    Response.Expires = 0;
    Response.ExpiresAbsolute = DateTime.Now.AddDays( -1 );
    Response.CacheControl = "no-cache";
    %>
    Last edited by Curtis Rutland; Aug 22 '08, 01:25 PM. Reason: Added Code Tags - Please use the # button

    Comment

    • yvrmurari
      New Member
      • Aug 2008
      • 4

      #3
      <Script>
      window.history. forward(1);
      </Script>

      Add the above code in between your head tag, in the page where don't want to go back

      Ex: Add the above code in Page1 and if you click on Logout in this page and u go to Page 2

      Now if you click back button, u can't go back to page1

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Originally posted by yvrmurari
        <Script>
        window.history. forward(1);
        </Script>
        I believe that code only works for IE yes?

        Comment

        • rjvrnjn
          New Member
          • Apr 2007
          • 26

          #5
          In my point of view this approach of disabling the back button once the user is logged out is not the best way to achieve what you intend. I would rather suggest that you check if the user is logged in or not (through Session ID) and if not then redirect them to the login page.

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6
            Assuming you disable the cache.

            Comment

            • raam
              New Member
              • Jun 2008
              • 11

              #7
              Thank you very much.

              Comment

              Working...