Silverlight Crossdomain

后端 未结 13 564
面向向阳花
面向向阳花 2021-01-01 10:52

I\'ve seen a lot of links to MSDN and \"works on my machine!\" answers so I\'d like to ask my question with the exact steps to duplicate what I\'m doing. Because we are usin

相关标签:
13条回答
  • 2021-01-01 11:43

    It worked in my pc successfully, you can place your

    clientaccesspolicy.xml

    <?xml version="1.0" encoding="utf-8"?> <access-policy>  
      <cross-domain-access>
         <policy>
           <allow-from http-request-headers="*">
             <domain uri="*"/>
           </allow-from>
           <grant-to>
             <resource path="/" include-subpaths="true"/>
           </grant-to>
         </policy>
       </cross-domain-access> 
    </access-policy>
    

    both your project directory and your webservices root.

    0 讨论(0)
  • 2021-01-01 11:44

    The problem could be that your development server is not able to serve the xml file, try this - explicitly make it available through WebGet

    [ServiceContract]
        public interface ICrossDomainService
        {
            [OperationContract]
            [WebGet(UriTemplate = "ClientAccessPolicy.xml")]
            Message ProvidePolicyFile();
        }
    

    and then the ProvidePolicyFile() can be

    public System.ServiceModel.Channels.Message ProvidePolicyFile()
            {
                FileStream filestream = File.Open(@"ClientAcessPolicy.xml", FileMode.Open);
                // Either specify ClientAcessPolicy.xml file path properly
                // or put that in \Bin folder of the console application
                XmlReader reader = XmlReader.Create(filestream);
                System.ServiceModel.Channels.Message result = Message.CreateMessage(MessageVersion.None, "", reader);
                return result;
            }
    
    0 讨论(0)
  • 2021-01-01 11:46

    I've encountered this problem (SL v5.0 and Visual Studio 2010), what fixed it for me is that I went into the Silverlight project properties >> Silverlight tab and selected "Require elevated trust when running in-browser"

    0 讨论(0)
  • 2021-01-01 11:48

    I was facing the same problem and take more than 3 days to figure out the Problem. I notice also when I was calling the internet Cloud Service WCF from a Silverlight app hosted in another web server it just shows Cross-Domain Errors. After looking into some posts I didn't solve the problem, even putting cross-domain.xml and clientaccesspolice.xml files in service root directory. So I just try to instead of using http://example.com I just change it to secure https://example.com and it just worked fine. The cross-domain errors disappears. service was called without problems.

    0 讨论(0)
  • 2021-01-01 11:49

    I've had this same problem a couple of times. In the past I've solved this by using the Web App as start up, but it looks like you've already done that.

    My post on the subject: http://www.donnfelker.com/silverlight-cross-domain-issue/

    0 讨论(0)
  • 2021-01-01 11:51

    Have you tried fiddler when using this through IE, you might be able to see the traffic silverlight is causing, such as which cross policy files it is looking for?

    0 讨论(0)
提交回复
热议问题