使用内容安全策略防止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级的支持。我尝试了很多方法,但没有明确的答案。我尝试过:
Is it possible prevent inline JavaScript on Internet Explorer 11 using CSP on ASP.NET WebForm? I know IE 11 does not support Content Security Policy Level 2 but it seen that support Level 1.0. I tried many way and there is not a clear answer out there. I tried:
- 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');
不起作用。
谢谢!
阿尔伯特·托雷斯
Thanks! Albert Torres
推荐答案
请参见此处-IE 11仅具有部分支持。
See here - IE 11 only has partial support.
Internet Explorer 10中的部分支持-11表示浏览器仅
通过使用
X-Content-Security-Policy 来支持
标头沙盒
指令
Partial support in Internet Explorer 10-11 refers to the browser only supporting the
sandbox
directive by using theX-Content-Security-Policy
header
但是,您可以尝试使用此沙盒
指令。 此处的说明:
However, you could try this sandbox
directive. Description here:
为请求的资源启用沙箱,类似于iframe
沙箱属性。沙箱应用了相同的原始策略,防止
弹出窗口,插件和脚本执行被阻止。您可以将
沙箱值保留为空以保留所有限制
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
这篇关于使用内容安全策略防止Internet Explorer 11上的内联JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!