- 移除头部信息 Server:Kestrel标识
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(x => x.AddServerHeader = false);//x.AddServerHeader==false去除标识
- 移除 X-Powered-By 标识
需要设置配置文件 webconfig
<?xml version="1.0" encoding="utf-8"?><configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<!-- 移除头部信息-->
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\TestApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration><!--ProjectGuid: cbc6f7a7-971f-469f-be32-a391d21c522a-->