Removing Vary:* response header from asp.net mvc 4.6
Asked Answered
F

1

9

How do I remove the Vary:* from the response header for all my requests in the WEB APP (ASP.NET MVC)

Thanks

Forehanded answered 12/10, 2017 at 7:29 Comment(3)
This appears to be for an older version but does this help: #9574001Thrashing
Do you want to remove the Vary header so that it does not appear in the responses at all or do you only want to remove Vary:* so Vary:Accept-Encoding would be okay?Kalif
In ASP.NET Core, you can use ResponseCacheAttribute, as explained in this Microsoft article.Sclerosed
A
0

The below code might help you.

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

or in your web.config like:

<system.webServer> 
    <httpProtocol>
        <customHeaders> 
            <remove name="Vary" />
        </customHeaders> 
    </httpProtocol> 
</system.webServer>
Amoy answered 19/6, 2018 at 1:20 Comment(1)
this https://mcmap.net/q/1321002/-how-to-supress-header-vary-when-using-outputcacheprofiles is likely the better approachIonize

© 2022 - 2024 — McMap. All rights reserved.