As a developer some times we may have to prevent users to visit back to the previously visited page . let us see the easy way to achieve this , I know that still many of us having the doubt “How to prevent visitor to click back button?” or “How to prevent user to visit last visited page ?”.
In the page’s code-declaration block, or in the code-behind class for the page, include code that sets the expiration policy for the page by using Response.Cache syntax. The following example sets expiration for the page as the @ OutputCache directive does in the previous procedure.
If we want to store the information in cache for a particular period time , then we can use the below given code.This code will help us to keep the data in Cache for a particular period of time.Once we set expiration for a page programmatically, we must set the Cache-Control header for the cached page as well. Use the HttpCachePolicy.SetCacheability method to set the HttpCacheability enumeration to Public.