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

誰能幫我將下面的代碼從 .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);
}

歡迎大家提出意見。

我的代碼和你一樣,正在從 2.1 遷移到 3.1。 最后,我找到了這個 SO 答案,引導我朝着正確的方向前進。 https://stackoverflow.com/a/55686482/537842

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

因此,只需將ResponseCacheFilter更改為ResponseCacheAttribute並刪除LoggerFactory就可以了!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM