如果想屏蔽 Server,X-AspNet-Version,X-AspNetMvc-Version 和 X-Powered-By,需要增加:
<httpProtocol><customerHeaders><remove name="Server" /><remove name="X-AspNet-Version" /><remove name="X-AspNetMvc-Version" /><remove name="X-Powered-By" /></customerHeaders>
</httpProtocol>
和
<system.web> <httpRuntime targetFramework="4.7.2" enableVersionHeader="false" /></system.web>
修改之后的web.config:
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on how to configure your ASP.NET application, please visithttps://go.microsoft.com/fwlink/?LinkId=301880 -->
<configuration><appSettings><add key="webpages:Version" value="3.0.0.0"/></appSettings><system.web><compilation targetFramework="4.7.2"/><httpRuntime targetFramework="4.7.2" enableVersionHeader="false" /></system.web><system.webServer> <httpProtocol><customHeaders><remove name="Server" /><remove name="X-AspNet-Version" /><remove name="X-AspNetMvc-Version" /><remove name="X-Powered-By" /></customHeaders></httpProtocol><security><requestFiltering removeServerHeader="true" /></security></system.webServer>
</configuration>
按照操作进行设置操作后,会看到X-AspNet-Version不再显示