移除Server
借助IIS URL Rewrite Module,添加如下的重写规则:
<rewrite>
<allowedServerVariables>
<add name="REMOTE_ADDR" />
</allowedServerVariables>
<outboundRules>
<rule name="REMOVE_RESPONSE_SERVER">
<match serverVariable="RESPONSE_SERVER" pattern=".*" />
<action type="Rewrite" />
</rule>
</outboundRules>
</rewrite>
重写规则存放在C:WindowsSystem32inetsrvconfigapplicationHost.config中。
Add this to your global.asax.cs:
protected void Application_PreSendRequestHeaders()
{
Response.Headers.Remove("Server");
Response.Headers.Remove("X-AspNet-Version");
Response.Headers.Remove("X-AspNetMvc-Version");
}