如何删除ASP.Net MVC默认HTTP头? [英] How to remove ASP.Net MVC Default HTTP Headers?
问题描述
在我与台合作,这些HTTP标头的响应MVC应用程序中的每一页:
Each page in an MVC application I'm working with sets these HTTP headers in responses:
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
X-AspNetMvc-Version: 2.0
我如何prevent这些展示?
How do I prevent these from showing?
推荐答案
在搭载在IIS中的自定义标题。改变它依赖于IIS版本所使用。有关如何修改或删除一些信息,在这里看到:
The "powered by" is a custom header in IIS. Changing it depends on the version of IIS you are using. For some information on how to modify or remove, see here:
<一个href=\"http://www.iis.net/ConfigReference/system.webServer/httpProtocol/customHeaders\">http://www.iis.net/ConfigReference/system.webServer/httpProtocol/customHeaders
要删除MVC头部,
在Global.asax中,在应用程序启动事件:
In Global.asax, in the Application Start event:
MvcHandler.DisableMvcResponseHeader = true;
在web.config
将这个摆脱的X ASPNET-版本头的:
Put this in the web.config get rid of the X-AspNet-Version header:
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>
这篇关于如何删除ASP.Net MVC默认HTTP头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!