一切福田,不離方寸,從心而覓,感無不通。

Asp.Net完美隐藏服务器信息

首先在Global.asax.cs里增加:

protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
{
HttpContext.Current.Response.Headers.Set("Server", "w3cnet.com");
HttpContext.Current.Response.Headers.Remove("X-AspNet-Version");
HttpContext.Current.Response.Cookies.Remove(".ASPXAUTH");
}

然后web.config的system.webServer节点下增加:

<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>

再看看响应头,或用站长工具查看,完美隐藏。

参考资料:

http://www.yn-s.com/news/Details/93