Removing X-Powered-By ASP.Net

Do not show response header

Server Microsoft-IIS/7.5
X-AspNetMvc-Version 3.0
X-AspNet-Version 4.0.303319
X-Powered-By ASP.NET
Removing X-AspNet-Version

Web.config

<system.web>
<httpRuntime enableVersionHeader=”false”/>

Removing X-AspNetMvc-Version

Global.asax.cs

protected void Application_Start()
{
MvcHandler.DisableMvcResponseHeader = true;
}

Removing or changing Server

In Global.asax.cs add this:

protected void Application_PreSendRequestHeaders()
{
//Response.Headers.Remove(“Server”); //Remove header
Response.Headers.Set(“Server”,”ServerName”); //Change Server header
Response.Headers.Remove(“X-AspNet-Version”); //alternative to above solution
Response.Headers.Remove(“X-AspNetMvc-Version”); //alternative to above solution
}

Removing or changing X-Powered-By

IIS 7 – You can also remove the X-Powered-By header by including these lines to the <system.webServer> element:

<httpProtocol>
<customHeaders>
<remove name=”X-Powered-By” />
</customHeaders>
</httpProtocol>

or manually go to IIS7 Management Console and open HTTP Response Headers

Source: https://ict.ken.be/removing-x-powered-by-aspnet-and-other-version-headers

ASP.NET C# MVC5

ASP.NET C# MVC5

Related Posts

About The Author

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.