【问题标题】:how to set httpheaders in asp.net mvc如何在asp.net mvc中设置httpheaders
【发布时间】:2011-02-05 10:23:01
【问题描述】:

我需要设置 http 标头来禁用 ie (7-8) 缓存(它会干扰我的 ajax 功能)。 我尝试将此代码插入到我的 site.master 的头部,但没有结果 -

 <META HTTP-EQUIV="Pragma"
CONTENT="no-cache"> <META
 HTTP-EQUIV="Expires" CONTENT="-1">

如何以及在何处设置 HTTP 标头? 或者你有更好的解决 ie 缓存问题的方法吗?

问候。

【问题讨论】:

    标签: asp.net-mvc ajax internet-explorer caching http-headers


    【解决方案1】:

    试试:

    [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
    

    这个属性,放置在控制器类中,禁用缓存。由于我不需要在我的应用程序中缓存,我将它放在我的 BaseController 类中:

    [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
    public abstract class BaseController : Controller
    {
    

    关于 OutputCacheAttribute 的描述很好:Improving Performance with Output Caching

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 2013-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多