asp.net mvc移除X-AspNet-Version、X-AspNetMvc-Version、Server
https://www.cnblogs.com/eggTwo/p/11993340.html
asp.net mvc程序部署到IIS,,返回的HTTP头中包含Server, X-Powered-By, 和 X-AspNet-Version、X-AspNet-Version信息. 这些信息有时给攻击者找寻你的站点漏洞提供的依据.
如下图所示:

1.移除X-AspNet-Version
在webconfig中做如下配置:

2.移除X-AspNetMvc-Version
在Global.asax中做如下配置

3.移除Server
3.1自定义server处理模型:
//移除http相应中的server Server: Microsoft-IIS/10.
public class CustomHeaderModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreSendRequestHeaders += OnPreSendRequestHeaders;
}
public void Dispose()
{
throw new NotImplementedException();
}
void OnPreSendRequestHeaders(object sender, EventArgs e)
{
//HttpContext.Current.Response.Headers.Remove("Server");
// 你可以在此设置
HttpContext.Current.Response.Headers.Remove("Server");
}
}
3.2在webconfig中做如下配置:
<add name="CustomHeaderModule" type="EUQ.Boss.App_Start.CustomHeaderModule" />

4.移除X-Powered-By: ASP.NET
打开IIS管理器,定位到当前站点,找到HTTP响应标头

删除节点:

如上操作相当于在webconfig中做如下配置:
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>



浙公网安备 33010602011771号