Each page in an MVC application I'm working with sets these HTTP headers in responses:
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
X-AspNetMvc-Version: 2.0
How do I prevent these from showing?
Each page in an MVC application I'm working with sets these HTTP headers in responses:
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
X-AspNetMvc-Version: 2.0
How do I prevent these from showing?
As described in Cloaking your ASP.NET MVC Web Application on IIS 7, you can turn off the X-AspNet-Version header by applying the following configuration section to your web.config:
and remove the X-AspNetMvc-Version header by altering your Global.asax.cs as follows:
As described in Custom Headers You can remove the "X-Powered-By" header by applying the following configuration section to your web.config:
There is no easy way to remove the "Server" response header via configuration, but you can implement an
HttpModule
to remove specific HTTP Headers as described in Cloaking your ASP.NET MVC Web Application on IIS 7 and in how-to-remove-server-x-aspnet-version-x-aspnetmvc-version-and-x-powered-by-from-the-response-header-in-iis7.In Asp.Net Core you can edit the web.config files like so:
You can remove the server header in the Kestrel options:
The X-Powered-By header is added by IIS to the HTTP response, so you can remove it even on server level via IIS Manager:
You can use the web.config directly:
For the sake of completeness, there is another way to remove the
Server
header, using regedit.See this MSDN blog.
I'd rather find a proper solution using the Web.config, but using
<rewrite>
is not good because it requires the rewrite module to be installed, and even then it won't really remove the header, just empty it.The "powered by" is a custom header in IIS. Changing it depends on the version of IIS you are using. For some information on how to modify or remove, see here:
http://www.iis.net/ConfigReference/system.webServer/httpProtocol/customHeaders
To remove the MVC header,
In Global.asax, in the Application Start event:
Put this in the web.config get rid of the X-AspNet-Version header:
You can also remove them by adding code to your global.asax file: