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

Sam*_*pat 7 response-headers asp.net-mvc-4

如何从WEB APP(ASP.NET MVC)中的所有请求的响应头中删除Vary:*

谢谢

小智 0

下面的代码可能对您有帮助。

protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
    HttpContext.Current.Response.Headers.Remove("Vary");
}
Run Code Online (Sandbox Code Playgroud)

或者在你的 web.config 中,例如:

<system.webServer> 
    <httpProtocol>
        <customHeaders> 
            <remove name="Vary" />
        </customHeaders> 
    </httpProtocol> 
</system.webServer>
Run Code Online (Sandbox Code Playgroud)