从响应ASP.NET:如何删除如X供电,通过IIS自定义页眉? [英] How to delete IIS custom headers like X-Powered-By: ASP.NET from response?
问题描述
在 IIS 7.0
集成模式
删除所有与头 Response.ClearHeaders后()
IIS会添加一些其他的头文件,如服务器
和 X-技术,通过
揭示不错信息给黑客。我怎样才能阻止这种行为(考虑我还需要添加我的自定义头)?
In IIS 7.0
integrated mode
after deleting all headers with Response.ClearHeaders()
IIS would add some other headers like Server
and X-Powered-By
which reveals good information to hackers. How can I stop this behavior (consider I still need to add my custom headers) ?
推荐答案
您可以将它添加到你的web.config:
You can add this to your Web.Config:
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
</system.webServer>
更新:如果你使用MVC框架我也建议删除 X-AspNetMvc-版本
和 X-ASPNET,版本
头为好。这是由你的的Global.asax
文件中设置 MvcHandler.DisableMvcResponseHeader = TRUE
和&LT完成;&的System.Web GT;&LT;的httpRuntime enableVersionHeader =false的/></system.web>
在的Web.config
分别。
Update: if you're using the MVC framework I would also recommend removing the X-AspNetMvc-Version
and X-AspNet-Version
headers as well. This is accomplished by setting MvcHandler.DisableMvcResponseHeader = true
in your Global.asax
file and <system.web><httpRuntime enableVersionHeader="false" /></system.web>
in your Web.config
respectively.
这篇关于从响应ASP.NET:如何删除如X供电,通过IIS自定义页眉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!