无法设置HTTP在ASP.NET/IIS7经典模式Vary头部 [英] Can't set HTTP Vary header in ASP.NET/IIS7 classic mode
问题描述
首先,一些背景知识。我写了一个自定义HTTP COM $为ASP.NET p $ pssion模块。我的机器有Windows 7旗舰版,附带了IIS7。我的生产环境中使用IIS6。
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.
我遇到的问题是,资源专家的Droid(redbot.org)告诉我,我需要一个头添加到我的反应正确支持COM pression:有所不同:接受编码
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"
在IIS7集成模式,它工作正常。然而,在经典模式,这是怎么我的应用程序运行,最终,我不能让我的code输出使用任何Response.AppendHeader(),Response.Cache.SetVaryByCustom(的)这个头,或Response.Cache.VaryByHeaders。
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.
我使用通配符处理程序映射,所以在ASP.NET经典模式看到所有的请求均匀。
I'm using a wildcard handler mapping, so ASP.NET sees all requests even in classic mode.
推荐答案
我知道你说你尝试过这了,但这里的通常的做法:
I realize you said you tried this already, but here's the usual approach:
this.Response.Cache.SetVaryByCustom("Accept-Encoding");
您可以尝试调用该方法,在后期的生命周期,如 END_REQUEST
在一个HttpModule。
You might try calling that method late in the life cycle, such as from End_Request
in an HttpModule.
如果不工作,遗憾的是,在IIS6,你需要使用ISAPI设置自定义HTTP标头。
If that doesn't work, unfortunately, in IIS6, you will need to use an ISAPI to set custom HTTP headers.
FWIW,内置的COM pression系统应该自动为您设置的标题。
FWIW, the built-in compression system should set that header automatically for you.
这篇关于无法设置HTTP在ASP.NET/IIS7经典模式Vary头部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!