When you click on browser back button, it brings page from cache not from server, But user will not be able to perform any action on page displayed after back button. So I want to to remove that pages in cache how can I achieve this asp.net core?
Asked
Active
Viewed 1,216 times
-1
-
https://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers – Mahdi Sep 14 '17 at 07:46
-
5Possible duplicate of [How to control web page caching, across all browsers?](https://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers) – Tom Sep 14 '17 at 07:49
-
yes thanks to both but i found this code `Response.Cache.SetCacheability(HttpCacheability.NoCache); // HTTP 1.1. Response.Cache.AppendCacheExtension("no-store, must-revalidate"); Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. Response.AppendHeader("Expires", "0"); // Proxies.` everywhere but don't know how to use it in asp.net core where i need to paste it? – Ali Shan Sep 14 '17 at 07:54
2 Answers
0
Add this to page_load
Response.Cache.SetCacheability(HttpCacheability.NoCache);
This is the only true answer although it's important to know that it's only a request to the browser to stop caching - it doesn't necessarily have to follow.
This needs to be included on every page you don't want the user to 'back button' onto.

R. Bandi
- 113
- 11
0
Add the below mentioned attribute to the action methods in .net core.
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]

hemanth gali
- 61
- 9