新闻建站cms系统、政府cms系统定制开发

广州网站建设公司-阅速公司

asp.net新闻发布系统、报纸数字报系统方案
/
http://www.ysneo.com/
广州网站建设公司
您当前位置:首页>网站技术

网站技术

删除Server HTTP头

发布时间:2019/4/6 13:01:19  作者:Admin  阅读:443  

广告:阿里云采购优惠专区

下载UrlScan

Download the setup MSI file for UrlScan 3.1 from one of the following URLs to your computer:

x86: http://www.microsoft.com/downloads/details.aspx?FamilyID=ee41818f-3363-4e24-9940-321603531989

x64: http://www.microsoft.com/downloads/details.aspx?FamilyID=361e5598-c1bd-46b8-b3e7-3980e8bdf0de

安装UrlScan(需要安装IIS-Metabase,即IIS 6 元数据库兼容性组件)后,

修改 C:\Windows\System32\inetsrv\urlscan\UrlScan.ini 文件,设置 RemoveServerHeader=1

然后重启IIS

二、StripHeaders

下载:https://github.com/Dionach/StripHeaders/releases

我们只要下载msi文件点击安装,然后重启iis就可以了。

做完之后,再打开网站,就会看到,所有返回的请求头里,server信息以及X-Powered-By、X-AspNet-Version、X-AspNetMvc-Version等都消失了,并且csp也正确反馈出来了。

注意:如果没有效果,或是页面报错了,可能是系统用户权限不足,需要手动注册一下这个StripHeaders。

可以用管理员权限打开命令行窗口,执行如下命令:

C:\Windows\System32\inetsrv\appcmd.exe install module /name:StripHeadersModule /image:%windir%\system32\inetsrv\stripheaders.dll /add:true /lock:true

然后再重启IIS服务,就可以了。

三 只能在集成模式下用

MvcHandler.DisableMvcResponseHeader = true;

void Application_Start(object sender, EventArgs e)

{

// 其它内容

// 移除 X-AspNetMvc-Version

MvcHandler.DisableMvcResponseHeader = true;

}

protected void Application_PreSendRequestHeaders(object sender, EventArgs e)

{

HttpApplication app = sender as HttpApplication;

if (app != null && app.Context != null)

{

//移除Server

app.Context.Response.Headers.Remove("Server");

//修改Server的值

app.Context.Response.Headers.Set("Server", "Tom");

//移除X-AspNet-Version,和上面效果一樣

app.Context.Response.Headers.Remove("X-AspNet-Version");

//移除X-AspNetMvc-Version,和上面效果一樣

// app.Context.Response.Headers.Remove("X-AspNetMvc-Version");

}

}

广告:阿里云新人采购专场

相关文章
HTTP头
cms新闻系统购买咨询
扫描关注 广州阅速软件科技有限公司
扫描关注 广州阅速科技