简体   繁体   English

什么相当于 ResponseCacheFilter(NameSpace- Microsoft.AspNetCore.Mvc.Internal) In.Net Core 3.1

[英]What is equivalent of ResponseCacheFilter(NameSpace- Microsoft.AspNetCore.Mvc.Internal) In .Net Core 3.1

Can anyone please help me to transform below code from .NET Core 2.2 to 3.1?谁能帮我将下面的代码从 .NET Core 2.2 转换为 3.1?

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc(options =>
    {
        options.Filters.Add(
            new ResponseCacheFilter(
                new CacheProfile { NoStore = true },
                LoggerFactory));
    }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}

Any suggestions would be welcome.欢迎大家提出意见。

I had the same code as you and were migrating from 2.1 to 3.1.我的代码和你一样,正在从 2.1 迁移到 3.1。 At last I found this SO answer that guided me in the right direction.最后,我找到了这个 SO 答案,引导我朝着正确的方向前进。 https://stackoverflow.com/a/55686482/537842 https://stackoverflow.com/a/55686482/537842

services
    .AddMvc(o =>
    {
        o.Filters.Add(new ResponseCacheAttribute { NoStore = true, Location = ResponseCacheLocation.None });
    });

So, just change ResponseCacheFilter to ResponseCacheAttribute and drop the LoggerFactory and you should be good to go!因此,只需将ResponseCacheFilter更改为ResponseCacheAttribute并删除LoggerFactory就可以了!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决.Net core 3.1中的“无法加载类型'Microsoft.AspNetCore.Mvc.MvcJsonOptions'”? - How to resolve "Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' " in .Net core 3.1? 从 2.1 迁移到 3.1.Net Core,Microsoft.AspNetCore.App 的替代品是什么? - Migrating from 2.1 to 3.1 .Net Core, What is the Replacement of Microsoft.AspNetCore.App? 无法从程序集“Microsoft.AspNetCore.Mvc.Core”加载类型“Microsoft.AspNetCore.Mvc.Internal.IActionSelectorDecisionTreeProvider” - Could not load type 'Microsoft.AspNetCore.Mvc.Internal.IActionSelectorDecisionTreeProvider' from assembly 'Microsoft.AspNetCore.Mvc.Core 使用 .NET-Standard 2.0 项目构建 ASP.NET-Core 3.1 会导致冲突的 Microsoft.AspNetCore.Mvc.Analyzers 程序集 - Building ASP.NET-Core 3.1 with .NET-Standard 2.0 projects leads to conflicting Microsoft.AspNetCore.Mvc.Analyzers assemblies .NET Core 3.1 中实体的等价物是什么? - What can be the equivalent of entity in .NET Core 3.1? System.TypeLoadException:asp.net 核心中的“Microsoft.AspNetCore.Mvc.Razor.Internal.FileProviderRazorProjectFileSystem”类型中的“方法“GetItem” - System.TypeLoadException: 'Method 'GetItem' in type 'Microsoft.AspNetCore.Mvc.Razor.Internal.FileProviderRazorProjectFileSystem' in asp.net core Microsoft.AspNetCore.Authorization 在 .NET Core 3.1 项目中升级到 5.0 - Microsoft.AspNetCore.Authorization get upgraded to 5.0 in .NET Core 3.1 project 控制台应用程序已更新为 .Net Core 3.1 错误找不到框架“Microsoft.AspNetCore.App”,版本“3.1.0” - Console App Updated to .Net Core 3.1 Error The framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found ASP.NET Core 3.1 相当于HttpControllerContext 和HttpActionContext 是什么? - What is the ASP.NET Core 3.1 equivalent to HttpControllerContext and HttpActionContext? 无法在我的.NET Core单元测试项目中加载文件或程序集Microsoft.AspNetCore.Mvc.ApiExplorer - Could not load file or assembly Microsoft.AspNetCore.Mvc.ApiExplorer in my .NET Core unit test project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM