How do you create/obtain a cross domain policy for an iis7 wcf service?

我是研究僧i 提交于 2019-12-11 18:41:42

问题


The missing link in my IIS7 + Silverlight 3.0 + WCF Service app is the cross domain policy. Are there any instructions on how to create/obtain such a policy. I understand that there are two xml files that need to go in the web root of the app. What do I put in them, how do I format them, does some template exist which indicates which fields need to be filled in? Are there instructions somewhere on msdn which explain how to do this? I'm just about out of possible terms to query google with, any pointers would be appreciated.

Thanks, Brian


回答1:


Silverlight looks for clientaccesspolicy.xml (which is specific to silverlight) if thats not found it will fall back on crossdomain.xml which can also be used by flash for instance. You only need one of those (sockets only work with clientaccesspolicy.xml but webclient and http work with both).

Lets stick with clientaccesspolicy.xml for now since there are less caveats and the crossdomain.xml support was only added to catch up with flash since public services like flickr already have one.

The DTD including description for clientaccesspolicy.xml is at this page on MSDN

this basic example should get your started

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from>      
        <domain uri="*"/> <!-- Allows calls from every domain -->
      </allow-from>      
      <grant-to>      
        <resource path="/api" include-subpaths="false"/> <!-- Only allows domain/api? to be called nothing else including api.txt, api/foo etc... -->
      </grant-to>      
    </policy>
  </cross-domain-access>
</access-policy>



回答2:


Well, I think this might be the answer, but other answers are certainly welcome for discussion, esp. since we cant close the thread yet anyway...

http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx



来源:https://stackoverflow.com/questions/1325118/how-do-you-create-obtain-a-cross-domain-policy-for-an-iis7-wcf-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!