c# - 自定义 OutputCache 提供程序不工作(调用 get 但未设置或添加)

标签 c# asp.net asp.net-mvc-4 caching outputcache

在 ASP.NET MVC4 应用程序中,我定义了一个自定义输出缓存提供程序。

我的配置是这样的:

<system.web>
       <caching>
      <outputCache defaultProvider="DiskOutputCache" enableOutputCache="true"  >
        <providers>
          <add name="DiskOutputCache"  type="ProExam.DMC.MvcUtil.DiskOutputCache, ProExam.DMC.MvcUtil, Version=1.0.0.0, Culture=neutral"/>
        </providers>
      </outputCache>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="forever" duration="2147483647" varyByParam="id" />
        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>

我有这样的操作:

    [OutputCache(CacheProfile = "forever")]
    public ActionResult View(UrlParamString id)
    {
    ...
    }

当我在 Debug模式下运行时,只会调用自定义输出缓存提供程序的 get 方法。永远不要设置或添加。任何帮助将不胜感激...

最佳答案

尝试缩短持续时间。您定义了几乎无限的缓存持续时间,这意味着当应用程序运行时,它不会再次尝试存储您的缓存项。

持续时间以秒为单位设置...尝试 duration="10" 或其他东西,看看会发生什么。

除此之外,您还可以尝试在缓存配置文件中定义 enabled="true"location="Server"

关于c# - 自定义 OutputCache 提供程序不工作(调用 get 但未设置或添加),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22231105/

相关文章:

c# - 有没有办法为 ModelMetadata.RelatedEntities 获取 ModelMetadata.Properties?

asp.net - SQL MAX() 函数很慢,有没有更好的方法?

asp.net - 箭头键无法在 IE7 上滚动我们的网站

c# - 在 App_Web_*.dll 中找到了 index.cshtml 的副本,但正确的源代码与 App_Web_*.dll 中内置的版本不同,

c# - 值是逗号而不是点的范围验证

c# - FirstOrDefault 两种方式

c# - 将命名的简单类型与 LINQ to XSD 一起使用会导致编译器错误

c# - Rotativa PDF MVC3 分页

c# - 不使用 C# 命名空间有什么危险?

asp.net - 在面板内居中 RadioButtonList