How to send Cache-Control: no-cache in the header of an HTTP response?

Net 4 and C #.

I need to configure sending in the Cache-Control Browser ( Cache-Control: no-cache ) in the HTTP Response header for the web form page.

Any idea how to do this?

Thank you for your time.

+5
source share
3 answers

Try the following:

 Response.AppendHeader("Cache-Control", "no-cache"); 

However, you should be aware that only this header will not give you a reliable cross-browser way to prevent caching. See this answer for a more accurate solution: Make sure the webpage is not cached in all browsers

+5
source

In MVC, you can set it in the Controller class, so View does not use the cache;

 public ActionResult User() { Response.CacheControl = "no-cache"; return View(); } 
0
source

For the Dotnet kernel:

 Response.Headers.Append("Cache-Control", "no-cache, no-store, must-revalidate"); 
0
source

Source: https://habr.com/ru/post/1369643/


All Articles