C# 禁用ASP.net缓存

C# 禁用ASP.net缓存,c#,.net,asp.net,vb.net,C#,.net,Asp.net,Vb.net,是否有方法在所选页面上禁用asp.net缓存。如果可以从web.config完成这项工作,那就太好了 <!-- In the page itself --> <%@ OutputCache Location="None" %> 不幸的是,它必须在页面内完成。从web.config执行此操作并不容易。有关更多信息,请查看: 是的,如果您愿意创建自己的配置部分,您可以: 在配置部分中,输入如下内容: <cachingConfig> <path>

是否有方法在所选页面上禁用asp.net缓存。如果可以从web.config完成这项工作,那就太好了

<!-- In the page itself -->
<%@ OutputCache Location="None" %>
不幸的是,它必须在页面内完成。从web.config执行此操作并不容易。有关更多信息,请查看:


是的,如果您愿意创建自己的配置部分,您可以:

在配置部分中,输入如下内容:

<cachingConfig>
    <path>/Navigation/Menu.aspx</path>
    <path>/Target/Console.aspx</path>
    <path>/Target/Charting/Chart.aspx</path>
</cachingConfig>
编辑:提示:将init代码放在页面继承的基类中,这样它就只有一个位置

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();