Azure webrole excesive标头

编程入门 行业动态 更新时间:2024-10-16 22:23:22
本文介绍了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标头

本文发布于:2023-11-14 19:59:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588383.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Azure   webrole   excesive

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!