Browser 'Back Button' Issue in ASP.NET - Workaround

In development many times you come up scenario where the Back Button of browser becomes a nightmare. Recently, while developing one of Web Application in .NET i faced this issue.
I have a user control containing multiple child user control one of them is used to create new record for a business process.
After successfully creating record, it is possible that end user use back button which bring them back to the previous page for creating new record. And on submitting again this page will create a duplicate record (if there is no duplicate check done in code). To avoid this if you need to refresh the Create New page then add the following line in the page_load.
Thus when user use Back Button to browse to previous page the Create New Page will get refreshed and will be blanked out.

"
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
Response.AppendHeader("pragma","no-cache");
"

Happy Coding!!!

Comments

Popular posts from this blog

WCF WSDL location address Issue resolved when hosted over HTTPS with basicHTTPBinding

Yellow Background issue in Word to PDF conversion

Gmail tricks - create unlimited siblings of your Gmail address