Jus*_*ner 11
<!-- In the page itself -->
<%@ OutputCache Location="None" %>
Run Code Online (Sandbox Code Playgroud)
要么
// In the code-behind
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Run Code Online (Sandbox Code Playgroud)
不幸的是,它必须在页面内完成.从web.config开始,没有简单的方法.有关更多信息,请查看:
是的,如果您愿意创建自己的配置部分,可以:http://msdn.microsoft.com/en-us/library/2tw134k3.aspx
在您的配置部分中添加类似的内容,
<cachingConfig>
<path>/Navigation/Menu.aspx</path>
<path>/Target/Console.aspx</path>
<path>/Target/Charting/Chart.aspx</path>
</cachingConfig>
Run Code Online (Sandbox Code Playgroud)
如果您愿意,可以添加更多属性,例如持续时间.
然后,在页面的page_Init方法中,检查此配置部分并在适当的位置调用以下内容:
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Run Code Online (Sandbox Code Playgroud)
编辑:提示:将init代码放在页面继承的基类中,以便它只是一个位置.
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Run Code Online (Sandbox Code Playgroud)