【发布时间】:2011-08-11 11:14:01
【问题描述】:
有一个 HttpModule 可以更改响应标头中的服务器字段。但它在 ASP.NET/IIS7 经典模式下不起作用。删除或更改响应头中的服务器字段的解决方案是什么?
public class CloakHttpHeaderModule : IHttpModule
{
public void Init(HttpApplication app)
{
app.PreSendRequestHeaders += new EventHandler(context_PreSendRequestHeaders);
}
public void Dispose()
{
}
private void context_PreSendRequestHeaders(object sender, EventArgs e)
{
var context = ((HttpApplication)sender).Context;
context.Response.Headers.Set("Server", "Apache 2.0");
//HttpContext.Current.Response.Headers.Set("Server", "WSGIServer/0.1 Python/2.6.1");
}
}
【问题讨论】:
标签: asp.net iis-7 httpmodule