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:






0 comments:

Post a Comment

About Cullen

Cullen has been coding since 1991. He has been a Sr. Software Engineer/Architect for 11 years and counting. He enjoys coding for work as well as for fun. He loves learning from anyone and delights in sharing the little knowledge he possesses.

Followers