如何在所有响应标头中添加"X-Content-Type-Options:nosniff" [英] How can I add “X-Content-Type-Options: nosniff” to all the response headers

查看:5527
本文介绍了如何在所有响应标头中添加"X-Content-Type-Options:nosniff"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在IIS上运行ASP.NET MVC 3网站.在web.config中是否有一个标志或类似的东西可以做到这一点?

I am running an ASP.NET MVC 3 website on IIS. Is there a flag in web.config or something similar that can do this?

推荐答案

只要您使用的是IIS 7或更高版本,就如同将其添加到web.config一样简单.

As long as you're using IIS 7 or above, it's as simple as adding it to your web.config.

<configuration>
   <system.webServer>
      <httpProtocol>
         <customHeaders>
            <add name="X-Content-Type-Options" value="nosniff" />
         </customHeaders>
      </httpProtocol>
   </system.webServer>
</configuration>

或者您可以使用IIS管理GUI甚至命令行添加它们.看看 http://www.iis.net/configreference/system.webserver/httpprotocol/customheaders

Or you can add them using the IIS Management GUI, or even command line. Take a look at http://www.iis.net/configreference/system.webserver/httpprotocol/customheaders

这篇关于如何在所有响应标头中添加"X-Content-Type-Options:nosniff"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆