Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do i disable forward and backward button of my browser using session variable
Posted

The "Back" browser button (or any other browser button) cannot be actually disabled by a web application as the security context will not allow this.

What we can do is to somehow make sure that browser does not cache the web pages (which will cause the"Back" "Forward" buttons to grey out), and this can be easily done by expiring the Response. The code for this in ASP.NET 2.0:
C#
// Code disables caching by browser. Hence the back browser button
// grayed out and could not causes the Page_Load event to fire 
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
 
Share this answer
 
A session variable is only server side and will have no effect on a browser.
 
Share this answer
 
There is no way to disable the forward and back buttons, no matter what you use. As someone else said, the session is on the server, so even where it's possible to try to catch it, and stop it working for people who are not determined enough to kill the javascript you're using to do that, there's no way the session can be involved, except perhaps to tell you if you're blocking it or not.

It sounds to me like you know a few buzzwords and that's about it. You should read a basic book, once you understand what ASP.NET is, and what it does, you'll know why this was not a question that could be answered.
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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