javascript - 使用内容安全策略阻止 Internet Explorer 11 上的内联 JavaScript

标签 javascript asp.net web xss content-security-policy

是否可以使用 ASP.NET WebForm 上的 CSP 阻止 Internet Explorer 11 上的内联 JavaScript?我知道 IE 11 不支持内容安全策略级别 2,但它支持级别 1.0。我尝试了很多方法,但没有明确的答案。我试过了:

  • Response.AddHeader("X-Content-Security-Policy", "script-src 'none'");
  • Response.AddHeader("X-Content-Security-Policy","script-src 'self'");
  • Response.AddHeader("Content-Security-Policy", "script-src 'self'");

它不工作。

谢谢! 阿尔伯特·托雷斯

最佳答案

参见 here - IE 11 仅提供部分支持。

Partial support in Internet Explorer 10-11 refers to the browser only supporting the sandbox directive by using the X-Content-Security-Policy header

但是,您可以试试这个 sandbox 指令。 Description here :

Enables a sandbox for the requested resource similar to the iframe sandbox attribute. The sandbox applies a same origin policy, prevents popups, plugins and script execution is blocked. You can keep the sandbox value empty to keep all restrictions in place

例如

X-Content-Security-Policy: sandbox

关于javascript - 使用内容安全策略阻止 Internet Explorer 11 上的内联 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42704605/

相关文章:

php - 产品具有属性(变体)数据库设计?

c# - 建议使用 c# 和 css 为用户提供选择以将页面字体大小更改为任何可能数字的方法

javascript - 本地时间到服务器时区的转换

javascript - 单击时将 Font Awesome 图标从一个动画变为另一个图标

javascript - 如何将复杂的参数发送到asp.net

c# - asp.net 认证看机器名

c# - 查看源代码中的viewsate ["x"]和__viewstate有什么区别?

php - 无法在 mysql 中使用列名 "desc"

javascript - 仅使用 toDataURL 操作像素

javascript - 检查我的应用程序是否已经使用 Cordova 运行