Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove X-AspNetMvc-Version from header response without touching source code file (Global.asax.cs)?

I need to disable the X-AspNetMvc-Version from the response header of a large number of applications. The server where the applications are hosted has just the content and config files Global.asax, web.config, app.config for the application and source code files (*.cs) reside with some other team.

I could only find the solution as adding MvcHandler.DisableMvcResponseHeader = true; to Global.asax.cs. Any alternative solution(s) that involves working with any config file(s)?

like image 622
Chitra Belwal Avatar asked Dec 16 '13 05:12

Chitra Belwal


1 Answers

Set enableVersionHeader to false in your web.config is an alternate, I would prefer the web.config change to a handler solution like you have, obviously, since you will not need to access global.asax.cs to make the change:

just copy this line into the web.config’s <system.web> section:

<httpRuntime enableVersionHeader="false" />

http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.enableversionheader(v=vs.110).aspx

http://madskristensen.net/post/Remove-the-X-AspNet-Version-header

like image 82
Brian Ogden Avatar answered Oct 05 '22 19:10

Brian Ogden