……………………………………………….Expertise in .NET Technologies

Disabling Back button in ASP.NET

Posted by Ravi Varma Thumati on October 20, 2009

In your application you might come across the situation where you need to disable back button. For example if you consider this scenario, user gets data which can change frequently from database to display it in the screen. From that screen user can go another page where he presses back button of browser to come back to this page again. During that time browser might show the page which is in cache because of which user might not see the appropriate data.

To avoid this you can open the browser without toolbar. So that user won’t see the back button. But in lots of cases we can’t do this. Other way for doing this is, don’t cache the page. So every time any page is requested it will go to the server. Hence user will get the current data.

For avoiding page to be cached, you need to set the following properties for response object.

Response.Buffer = True

Response.ExpiresAbsolute = Now ().Subtract (New TimeSpan (1, 0, 0, 0))

Response.Expires = 0

Response.CacheControl = “no-cache”


Gets or sets the absolute date and time at which to remove cached information from the cache.


Gets or sets the number of minutes before a page cached on a browser expires. If the user returns to the same page before it expires, the cached version is displayed.

Cache Control

Sets the Cache-Control HTTP header to Public or Private.

Possible values:

–          Public – may be cached in public shared caches

–          Private – may only be cached in private cache

–          No-cache – may not be cached

–          No-store – may be cached but not archived


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: