Remove IIS Header Bloat in ASP.NET MVC

When you create a new ASP.NET MVC project, you are going to get a lot of bloat headers of any response from the page. This is done by default and it’s sometimes annoying  because none of it is either necessary or helpful. Worse, it can be harmful as potential hackers can easily identify the system, for example.

Here is the default ASP.NET project’s response ot a request for a page:

Cache-Control:private

Content-Encoding:gzip

Content-Length:2616

Content-Type:text/html; charset=utf-8

Date:Wed, 11 Jun 2014 16:07:59 GMT

Server:Microsoft-IIS/8.0

Vary:Accept-Encoding

X-AspNet-Version:4.0.30319

X-AspNetMvc-Version:4.0

X-Powered-By:ASP.NET

The first thing you need to do is remove X-AspNetMvc-Version header. To remove this, simply open your Global.asax.cs file to Application_Start, then add this code:
MvcHandler.DisableMvcResponseHeader = true;

Read the rest of the tutorial here: http://www.codeproject.com/Tips/785867/ASP-NET-MVC-Remove-IIS-Header-Bloat

Leave a Reply

Your email address will not be published. Required fields are marked *