[英]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.