Http headers 删除HTTP头“;服务器";。在IIS 6中
我使用VS2008和IIS6。我想从Http头“server”中删除服务器标记。 我在Global.asax中使用了以下代码Http headers 删除HTTP头“;服务器";。在IIS 6中,http-headers,iis-6,Http Headers,Iis 6,我使用VS2008和IIS6。我想从Http头“server”中删除服务器标记。 我在Global.asax中使用了以下代码 void Application_PreSendRequestHeaders(object src, EventArgs e) { HttpContext.Current.Response.Headers.Remove("Server"); } 它显示错误“对象引用未设置为对象的实例”。 我如何解决这个问题?以下是对我(IIS6)有效的步骤: 在Web服
void Application_PreSendRequestHeaders(object src, EventArgs e)
{
HttpContext.Current.Response.Headers.Remove("Server");
}
它显示错误“对象引用未设置为对象的实例”。
我如何解决这个问题?以下是对我(IIS6)有效的步骤:
祝你好运 看看这里的答案:。它具有其他错误处理功能,可以修复您的错误:
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
// Remove the "Server" HTTP Header from response
HttpApplication app = sender as HttpApplication;
if (null != app && null != app.Request && !app.Request.IsLocal &&
null != app.Context && null != app.Context.Response)
{
NameValueCollection headers = app.Context.Response.Headers;
if (null != headers)
{
headers.Remove("Server");
}
}
}
这需要IIS管道模式,而在操作问题状态下,IIS6中不可用。