Click here to Skip to main content
16,021,041 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When i'm login to the login page the page will redirect to the Main page but When i'm pressing BackSpace button it will redirect to the login page My requirement is the page should not redrict to the login page
Posted
Comments
Sandeep Mewara 7-Jun-12 23:24pm    
Browser back button or backspace button?

This article[^] describes an approach to do this via Javascript. However, you need to watch out for the fact that this might not work on other browsers.

As per standard functionality, I would recommend you let the back browser button work as is, but manage sessions so that incase the user is still logged in, he need not log in again.

To see the login screen, the user needs to logout or the session should time out.
 
Share this answer
 
You can use either server side solution or client side (javascript solution)

Server side

After logging in use this code

C#
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetAllowResponseInBrowserHistory(False)

client side

include the following text in the head portion of each page.

JavaScript
</script>
        history.forward();
</script>
 
Share this answer
 
If browser back button then you can refer this tip to get an idea on how to handle it: Browser back button issue after logout[^]

If it's the backspace button, then you need to handle the backspace keyevent code in your page. Put a Javascript handling the key event and may be cancel the key defaultbehaviour to keep the page as is and not backspace. Then this method will have a downside of not able to edit text on the page - if needed, you have to reinvoke backspace event for that control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900