在ASP.Net和IIS中删除不必要的HTTP响应头,IIS响应头敏感信息(Server/X-AspNet-Version等)过滤
global.asax.cs文件添加如下代码
/// <summary> /// 移除http相应头 /// </summary> protected void Application_PreSendRequestHeaders() { Response.Headers.Remove("Server"); Response.Headers.Remove("X-AspNet-Version"); Response.Headers.Remove("X-AspNetMvc-Version"); }
protected void Application_Start() { MvcHandler.DisableMvcResponseHeader = true;//移除X-AspNetMvc-Version HTTP头 }
webconfig添加下面配置去掉X-Powered-By
<httpProtocol> <customHeaders> <remove name="X-Powered-By" /> </customHeaders> </httpProtocol>
作者:apegu
地址:http://www.cnblogs.com/jiangqw
如果,您认为阅读这篇博客让您有些收获,不妨点击一下推荐按钮。