本文介绍了Azure webrole excesive标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个在Azure Web角色中运行的网站。我针对asafaweb对该网站进行了测试,并收到了过度标题警告。
I have a website running in Azure Web Roles. I tested the site against asafaweb and got an "Excessive Headers" warning.
基本上,Azure发送IIS版本和版本作为标题的一部分。
Basically Azure sends out the IIS version and the version as part of the header.
有很多关于如何在IIS中关闭这些标题的信息,但是如何在Azure中关闭它们?
There is plenty of information on how to turn these headers off in IIS, but how do I turn them off in Azure?
推荐答案我在大多数项目中使用这些来隐藏这些标题:
This is what I use in most projects to hide these headers:
Global.asax。 cs (仅适用于MVC项目)
Global.asax.cs (only applies to MVC projects)
protected void Application_Start() { MvcHandler.DisableMvcResponseHeader = true; }自定义HttpModule
public class RemoveHeadersHttpModule : IHttpModule { public void Init(HttpApplication context) { context.PreSendRequestHeaders += OnPreSendRequestHeaders; } private void OnPreSendRequestHeaders(object sender, EventArgs e) { HttpContext.Current.Response.Headers.Remove("Server"); HttpContext.Current.Response.Headers.Remove("X-AspNet-Version"); } public void Dispose() { } }web.config
<system.webServer> <httpProtocol> <customHeaders> <remove name="Server" /> <remove name="X-Powered-By" /> </customHeaders> </httpProtocol> <modules runAllManagedModulesForAllRequests="true"> . . . <add name="RemoveHeadersHttpModule" type="MyNamespace.RemoveHeadersHttpModule"/> </modules> . . . </system.webServer>更多推荐
Azure webrole excesive标头
发布评论