0

Hi all . I have tried different methods but i am still unable to disable my browsers back button. plz help me out. some of the methods that i have tried are -:

1)

on logout click i wrote this code in my .aspx.cs file

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();

2) Also i tried this java script function

<script type="text/javascript" language="javascript">
    function cancelBack()   
    {   
        if ((event.keyCode == 8 ||    
           (event.keyCode == 37 && event.altKey) ||    
           (event.keyCode == 39 && event.altKey))   
            &&    
           (event.srcElement.form == null || event.srcElement.isTextEdit == false)   
          )   
        {   
            event.cancelBubble = true;   
            event.returnValue = false;   
        }   

        if (window.event.keyCode == 13) 
        {
            event.returnValue=false; 
            event.cancel = true;
        }
    }   
    </script>

Edited by Nick Evan: Fixed formatting

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by ujjwal uniyal
0

Don't disable the back button unless you have a really good reason. Seeing as you seem to be doing it on the logout page, you can achieve the same effect through session state. If session state says user is logged out (you update it when they do log out) when they go to a page that requires log in status, they get redirected to the login page.

0

All i wanted to do is don let the unauthorized user even see the admin section. When user logs out , session ends , but still someone can see the pages under admin section that the user visited, although he can't use it. Can u please suggest something by which i can clear the cache ???

By the way Thanks for the Answer.

0

Are you referring to seeing the pages in the browser history and cache or the ability to move backward through visited pages by pressing the back button? Sorry, I'm not sure exactly where the unauthorized user would see the pages.

0

When the authorized user logs out and then some anonymous user comes and clicks the back button , he can see the Functionality although he can't use it. I want to clear the cache. Doesn't that means it will disable the back button because now there is nothing in the cache to where it can refer...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.