profile for Cullen Tsering at Stack Overflow, Q&A for professional and enthusiast programmers

Tuesday, March 22, 2011

Hide MVC version # and Asp.Net version # from HTTP Header


By default, Asp.Net and Mvc emit the version numbers in the HTTP header as below:


In the figure above, X-AspNet-Version is the Asp.net version and X-AspNetMvc-Version is version number of System.Web.Mvc version number as shown below:
























But for some reason that you don't want the world know that you're running your app on Asp.net and MVC, you can turn them off.

To remove  X-AspNet-Version from the header, set the value of enableVersionHeader of httpRuntime tag to false the web.config as follows:
  <system.web>
    <httpRuntime enableVersionHeader ="false" />

To remove X-AspNetMvc-Version from the header, you can modify the application_start event in Global.asax.cs as follows:
 protected void Application_Start()
        {
            MvcHandler.DisableMvcResponseHeader = true;

After making above changes in my app, the end result of the header looks like this:






About Cullen

My photo
Christian, Father, Software Developer/Architect who enjoys technology and using it to make people's lives easier!

Followers