如何在HTTP响应头中发送Cache-Control:no-cache?

净4和C#。

我需要在Web窗体页面的HTTP响应标头中设置发送到浏览器缓存控制( Cache-Control: no-cache )。

知道怎么做吗?

谢谢你的时间。

试试这个:

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

但是,您应该知道单独使用此标头不会为您提供可靠的跨浏览器方式来阻止缓存。 请参阅此答案以获得更准确的解决方案: 确保所有浏览器都不会缓存网页

在MVC中你可以在Controller类中设置它,所以View不使用缓存;

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