3

我有一个 MVC Web 项目,我正在尝试使用本地运行的 redis 缓存为一些页面设置 OutputCache,最终托管在 azure 中。

我已经用我的ActionResult装饰了

[OutputCache(CacheProfile = "cacheprofile1")]

并在我的 web.config system.web / 缓存下有以下内容

  <outputCacheSettings>
    <outputCacheProfiles>
      <add name="cacheprofile1" duration="1800" varyByParam="none"/>
    </outputCacheProfiles>
  </outputCacheSettings>

我的缓存提供程序已相应设置

     <outputCache defaultProvider="localRedisOutputCache">
        <providers>
          <add name="localRedisOutputCache" type="Microsoft.Web.Redis.RedisOutputCacheProvider" host="127.0.0.1" accessKey="" ssl="false" />
        </providers>
      </outputCache>

我的缓存中没有任何条目。如果我将我的 ActionResult 装饰更改为

[OutputCache(Duration=1800)]

它有效,但我宁愿不必针对每种方法手动设置它。

任何关于为什么缓存配置文件被忽略以及如何解决的想法将不胜感激。

4

0 回答 0