Thursday, May 29, 2014

How to remove ASP.NET response headers Server, X-AspNet-Version, X-AspNetMvc-Version and X-Powered-By?

Need two steps:
Step 1: add following code into Global.asax
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
        {
            HttpContext.Current.Response.Headers.Remove("X-Powered-By");
            HttpContext.Current.Response.Headers.Remove("X-AspNet-Version");
            HttpContext.Current.Response.Headers.Remove("X-AspNetMvc-Version");
            HttpContext.Current.Response.Headers.Remove("Server");
        }

AND

Step 2
Add following config into web.config file

    
      
        
        
      
    
  

No comments:

Post a Comment