The setup is as follows:
Windows Server 2022 Standard with IIS 10.
ASP .NET 4.8 based application, running with Integrated mode
and Application Pool Identity
.
Im trying to remove the following headers:
Server
, X-Powered-By
, X-ASPNet-Version
, X-ASPNetMVC-Version
.
No matter what is done, the headers remain.
Things tried:
Remove on server level from
RESPONSE HEADERS
theX-Powered-By
header - no effect, still shows up on dynamic content.Set enableVersionHeader in server applicationhost.config configuration file and in application configuration file with no effect:
<configuration>
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>
</configuration>
- Set on server level with no effect:
<configuration>
<system.webServer>
<security>
<requestFiltering removeServerHeader="true" />
</security>
</system.webServer>
</configuration>
Set the DisableServerHeader DWORD registry value to 1 and restarted IIS with no effect:
HKLM\SYSTEM\CurrentControlSet\Services\HTTP\Parameters!DisableServerHeader
Tried modifying the
Global.asax
to remove the ASPNetMVC header, but it broke the application.
I confirmed, that the changes on server level go down to the website level. I tried setting it up also manually in the web.config on the site. Same effect (none).
URL Scan is no longer available, so it is not an option. Last option seems to be to use URL Rewrite, but I would rather not use it if possible, given there are supposedly native solutions for that.
What am I doing wrong and is there something I am missing?
These kind of Headers can either be added at Website level or IIS at level. Once you click on Website in your IIS console, open HTTP Response headers, you should see the list of headers here along with the Entry Type. If the entry type is Inherited, that means this entry is still at your IIS level. You can validate this in your applicationhost.config.
You can either remove it from here or, you can remove this from the IIS Console, after clicking on the Server and open the HTTP Response headers, remove it and validate the response.
Seems like something went wrong with the site along the way. I deleted it and created it again, which somehow fixed the issue. The site
web.config
was still absolutely the same, but the header related changes started to work. And i do not know if its me not understanding or simply not working the way i expect it to do, but theX-ASPNetMVC-Version
had to be put in the application source code fileGlobal.asax.cs
, not in one at runtime (ie, after build/deploy). Thank you for the offered answers and help.I think you can edit web.config that should be distributed with your application and add following lines: