Can't set HTTP Vary header in ASP.NET/IIS7 classic mode

荒凉一梦 提交于 2019-12-24 00:53:49

问题


First, a little background. I have written a custom HTTP compression module for ASP.NET. My development machine has Windows 7 Ultimate, which comes with IIS7. My production environment uses IIS6.

The problem I'm having is, Resource Expert Droid (redbot.org) tells me that I need to add a header to my response to properly support compression: "Vary: Accept-Encoding"

On IIS7 in integrated mode, it works properly. However, in classic mode, which is how my application ultimately runs, I cannot get my code to output this header using any of Response.AppendHeader(), Response.Cache.SetVaryByCustom(), or Response.Cache.VaryByHeaders.

I'm using a wildcard handler mapping, so ASP.NET sees all requests even in classic mode.


回答1:


I realize you said you tried this already, but here's the usual approach:

this.Response.Cache.SetVaryByCustom("Accept-Encoding");

You might try calling that method late in the life cycle, such as from End_Request in an HttpModule.

If that doesn't work, unfortunately, in IIS6, you will need to use an ISAPI to set custom HTTP headers.

FWIW, the built-in compression system should set that header automatically for you.



来源:https://stackoverflow.com/questions/2075901/cant-set-http-vary-header-in-asp-net-iis7-classic-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!