使用自定义输出缓存提供程序RedisOutputCacheProvider时的ProviderException

rob*_*mzd 5 asp.net-mvc outputcache azure stackexchange.redis

Microsoft.Web.RedisOutputCacheProvider按照https://msdn.microsoft.com/en-us/library/azure/dn798898.aspx中的说明安装了nuget软件包,用于在多个服务器实例上运行的Azure Web App ,并且收到以下错误:

When using a custom output cache provider like 'MyRedisOutputCache', only the following expiration policies and cache features are supported:  file dependencies, absolute expirations, static validation callbacks and static substitution callbacks.
Run Code Online (Sandbox Code Playgroud)

配置设置如下:

<system.web>
  <caching>
    <outputCache defaultProvider="MyRedisOutputCache">
      <providers>
        <add name="MyRedisOutputCache" 
             type="Microsoft.Web.Redis.RedisOutputCacheProvider" 
             port="1234" 
             host="[my host]" 
             accessKey="[my access key]" 
             ssl="true" />
      </providers>
    </outputCache>
  </caching>
</system.web>
Run Code Online (Sandbox Code Playgroud)

我已经尝试将其设置connectionString为有效的StackExchange.Redis连接字符串,而不是设置单个端口/主机等...但仍然收到相同的错误.

我们还Microsoft.Web.RedisSessionStateProvider使用相同的设置在同一个Web应用程序中运行,没有任何问题.

任何帮助,将不胜感激.

Bil*_*son 4

将 RedisOutputCacheProvider 与采用某种 AuthorizeAttribute 风格的安全控制器操作一起使用似乎会导致异常。它对于AllowAnonymous 操作效果很好。以下内容可能会有所帮助:

使用 Azure 缓存(.NET MVC3 应用程序)时,为什么无法组合 [Authorize] 和 [OutputCache] 属性?