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?
To remove the Server header, within the Program.cs file, add the following option:
For dot net core 1, put add the option inside the .UseKestrel() call. For dot net core 2, add the line after UseStartup().
To remove X-Powered-By header, if deployed to IIS, edit your web.config and add the following section inside the system.webServer tag:
To remove the Server header, within your global.asax file add the following:
Add the following c# class to your project:
and then within your web.config add the following <modules> section:
However I had a problem where sub-projects couldn't find this module. Not fun.
Removing X-AspNetMvc-Version header
To remove the ''X-AspNetMvc-Version'' tag, for any version of .NET, modify your ''web.config'' file to include:
Thanks Microsoft for making this unbelievably difficult. Or maybe that was your intention so that you could track IIS and MVC installs across the world ...
As shown on Removing standard server headers on Windows Azure Web Sites page, you can remove headers with the following:
This removes the Server header, and the X- headers.
This worked locally in my tests in Visual Studio 2015.
I found this configuration in my
web.config
which was for aNew Web Site...
created in Visual Studio (as opposed to aNew Project...
). Since the question states a ASP.NET MVC application, not as relevant, but still an option.Update: Also, Troy Hunt has an article titled Shhh… don’t let your response headers talk too loudly with detailed steps on removing these headers as well as a link to his ASafaWeb tool for scanning for them and other security configurations.
You can change any header or anything in
Application_EndRequest()
try thisCheck this blog Don't use code to remove headers. It is unstable according Microsoft
My take on this: