从asp.net mvc 4.6中删除Vary:*响应头

9
我如何在我的WEB APP (ASP.NET MVC)中删除响应头中所有请求的Vary:* ?
谢谢。

2
这似乎是针对旧版本的,但这个链接有帮助吗:https://dev59.com/s2HVa4cB1Zd3GeqPkTGe - PeterJ
您想删除Vary头,以便它根本不出现在响应中,还是只想删除Vary:*,这样Vary:Accept-Encoding就可以了? - Harry
在ASP.NET Core中,您可以使用ResponseCacheAttribute,如此Microsoft文章所述。 - Ruud Helderman
1个回答

0
以下代码可能会对您有所帮助。
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
    HttpContext.Current.Response.Headers.Remove("Vary");
}

或者在你的 web.config 中添加如下内容:

<system.webServer> 
    <httpProtocol>
        <customHeaders> 
            <remove name="Vary" />
        </customHeaders> 
    </httpProtocol> 
</system.webServer>

这个 https://dev59.com/s2HVa4cB1Zd3GeqPkTGe#13509708 可能是更好的方法。 - CervEd

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接