从响应标头中删除服务器:Microsoft-IIS / 8.5标头

时间:2016-02-01 06:40:22

标签: iis http-headers httpresponse windows-server-2012-r2 iis-8.5

我的Windows Server 2012 R2上安装了IIS 8.5。我试图从我的回复中删除服务器:Microsoft-IIS / 8.5标头。

我尝试安装了URLScan,但无法安装,但出现以下错误

<div style="background-color: fff;height: 100%; width: 100%; overflow: hidden; margin: 0;position:relative;">
<div id="mask1" style="background:red;width:100px;height:100%;position:absolute;left:0top:10px;"></div>
<embed id="swf" width="100%" height="100%" name="plugin" src="http://zd.diyifanwen.com/Files/WordSwf/%E6%9D%A8.swf" type="application/x-shockwave-flash">
<div id="mask2" style="background:blue;width:600px;height:100px;position:absolute;right:0;bottom:0;"></div>
</div>

我尝试将其从我网站上的UrlRewrite设置中删除但它无效。任何人都可以帮忙。

1 个答案:

答案 0 :(得分:1)

我使用自定义模块清理应用内的标题:

public class HeadersCleanupModule : IHttpModule
{
    public void Init(HttpApplication context)
    {
        context.PostReleaseRequestState += application_PostReleaseRequestState;
    }


    void application_PostReleaseRequestState(object sender, EventArgs e)
    {
        HttpContext.Current.Response.Headers.Remove("Server");
        HttpContext.Current.Response.Headers.Remove("X-AspNet-Version");
        HttpContext.Current.Response.Headers.Remove("ETag");
    }


}
相关问题