禁用ASP.net缓存 [英] Disable ASP.net Cache

查看:176
本文介绍了禁用ASP.net缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来禁用所选页面上asp.net缓存。这将是很好,如果这可以从web.config中完成。

Is there a way to disable asp.net caching on selected page. It would be nice if this can be done from the web.config.

推荐答案

是的,你可以的,如果你愿意创建自己的配置部分:<一href="http://msdn.microsoft.com/en-us/library/2tw134k3.aspx">http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

Yes you can if you are willing to create your own config section: http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

在你的配置部分装上去一样,

In your config section put something like,

<cachingConfig>
    <path>/Navigation/Menu.aspx</path>
    <path>/Target/Console.aspx</path>
    <path>/Target/Charting/Chart.aspx</path>
</cachingConfig>

您可以如持续时间,如果你想添加更多的属性。

You could add more properties such as duration if you like.

然后,在你的页面的page_Init方法,检查配置部分,并调用以下酌情:

Then, on the page_Init method of your pages, check this configuration section and call the following where appropriate:

Response.Cache.SetCacheability(HttpCacheability.NoCache)

编辑:小提示:把初始化code。在您的网页继承一个基类,所以它只有一个地方

Tip: Put the init code in a base class that your pages inherit, so that it is only one place.

这篇关于禁用ASP.net缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆