2010-12-14 30 views

回答

2

所有这一切真正需要的是删除错误的Content-Length头,但是未在IIS6不允许的。不知道集成管道模式下的IIS7。对于使用您的过滤器的任何响应,将此更新应用于标题。这个想法是获得内容类型(所以你不打破任何非文本回应)和任何存在的cookie(所以你不要破坏身份验证),清除所有头(清除Content-Length),然后设置内容类型和Cookie。我们在HttpApplication.ReleaseRequestState事件中应用我们的过滤器,然后执行以下处理。因人而异。

HttpApplication app = (HttpApplication)sender; 
string ct = app.Response.ContentType; 
HttpCookie[] cookies = new HttpCookie[app.Response.Cookies.Count]; 
app.Response.Cookies.CopyTo(cookies, 0); 

app.Response.ClearHeaders(); 

app.Response.ContentType = ct; 
foreach (HttpCookie cookie in cookies) { app.Response.Cookies.Add(cookie); }