Protecting ASP.Net Page From Back button press

You can make your ASP.Net pages protected from browser back button press, while your data is not yet saved or to ensure the security of transactional data, eg: online banking, cms

You have to place the code inside ‘Page_Load’

example:

protected void Page_Load(object sender, EventArgs e)
{
//Empty Browser Cache on Back button Press
Response.Cache.SetExpires(DateTime.Parse(DateTime.Now.ToString()));
Response.Cache.SetCacheability(HttpCacheability.Private);
Response.Cache.SetNoStore();
Response.AppendHeader(“Pragma”, “no-cache”);
}
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s