使用内容安全策略阻止 Internet Explorer 11 上的内联 JavaScript
Prevent inline JavaScript on Internet Explorer 11 using 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
是否可以在 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 theX-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