Sunday 8 February 2015

ASP.NET Tips #22 - Removing X-Powered-By ASP.Net and other version headers

Most likely you do not want these headers to be displayed in your responses:

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

Removing X-AspNet-Version, In web.config add this:

   <httpRuntime enableVersionHeader="false"/>

Removing X-AspNetMvc-Version, In global.asax.cs add this:

protected void Application_Start()
   MvcHandler.DisableMvcResponseHeader = true;

Removing or changing X-Powered-By, IIS 7.5 - You can also remove the X-Powered-By header by including these lines to the element in Web.config:

         <clear />
         <remove name="X-Powered-By" />

Removing Server, In global.asax.cs add this:

protected void Application_PreSendRequestHeaders()

No comments :

Post a Comment