如何在web api angular中启用内容安全策略?

时间:2016-06-28 07:30:26

标签: javascript angularjs iframe content-security-policy

我想 为我的网络API启用内容安全策略,该策略用于我的角度应用

我看过一些引用,并在网络配置中添加了以下代码。

但我仍然可以通过w3schools中的iframe标记加载我的文件。它没有像 frame-ancestors'none' 这样的任何例外。 我需要在web api中添加除此之外的任何代码吗?或者仍然是web配置将处理所有请求?

  

注意 :请求网络API api时,我在申请网络API方法时不会为每次通话附加域和主机。

     

例如,

     

$ http.get( “/ API /用户/ UpdateUser两个”)。每次通话都需要附加吗?   这有必要吗?

我在web config中添加了以下代码

  <system.webServer>
   <httpProtocol>
      <customHeaders>
        <clear />
        <add name="X-Frame-Options" value="ALLOW-FROM http://localhost:4086" />
        <add name="Content-Security-Policy" value="frame-ancestors http://localhost:4086" />
      </customHeaders>
    </httpProtocol>

  </system.webServer>

我收到以下回复标题

I am getting the following response header

尊敬:https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options

0 个答案:

没有答案