加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 使用自定义输出缓存提供程序RedisOutputCachePro

发布时间:2020-12-16 03:30:16 所属栏目:asp.Net 来源:网络整理
导读:我已经按照此处的说明安装了nuget包Microsoft.Web.RedisOutputCacheProvider,用于在多个服务器实例上运行的Azure Web App,并且收到以下错误: When using a custom output cache provider like 'MyRedisOutputCache',only the following expiration policies
我已经按照此处的说明安装了nuget包Microsoft.Web.RedisOutputCacheProvider,用于在多个服务器实例上运行的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.

配置设置如下:

<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>

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

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

任何帮助,将不胜感激.

解决方法

将RedisOutputCacheProvider与使用AuthorizeAttribute的某些风格的安全控制器操作一起使用似乎会导致异常.它适用于AllowAnonymous操作.以下可能会有所帮助:

Why can’t I combine [Authorize] and [OutputCache] attributes when using Azure cache (.NET MVC3 app)?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读