6

Net 4 and C#.

I would need set send to Browser Cache-Control (Cache-Control: no-cache) in the HTTP Response header for a Web Form page.

Any idea how to do it?

Thanks for your time.

Kevin Kalitowski
  • 6,509
  • 4
  • 34
  • 52
GibboK
  • 68,054
  • 134
  • 405
  • 638

3 Answers3

8

Try this:

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

However, you should know that this header alone won't give you a reliable cross-browser way to prevent caching. See this answer for more accurate solution: Making sure a web page is not cached, across all browsers

Community
  • 1
  • 1
Dyppl
  • 11,795
  • 9
  • 45
  • 67
1

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

public ActionResult User()
{
    Response.CacheControl = "no-cache";
    return View();
}
Hernaldo Gonzalez
  • 1,827
  • 1
  • 21
  • 30
1

For dotnet core:

Response.Headers.Append("Cache-Control", "no-cache, no-store, must-revalidate");
Omar M.
  • 311
  • 2
  • 6