Cross Domain Policy error

Cross Domain Policy error

Old forum URL: forums.lhotka.net/forums/t/11079.aspx


shivam.ms posted on Monday, January 23, 2012

I am getting this error when try to create object in server from SilverLight UI

 

An error occurred while trying to make a request to URI 'http://localhost:1406/PTAppSchedulerSL.web/WcfPortal.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.

JonnyBee replied on Monday, January 23, 2012

Hi,

Normally, you will set the startup project to the website that host the Silverlight container.

I believe you try to run the Silverlight UI project directly - not the web project.

Alternatively - you will have to add cclientaccesspolicy and/or crossdomainpolicy. Read more here:

http://msdn.microsoft.com/en-us/library/cc197955%28v=vs.95%29.aspx

shivam.ms replied on Monday, January 23, 2012

Thank you so much Jhonny.   Luckily I already did that and now i am not getting that error.  But the object is not created and returned from server and i get the error message from callback that "The remote server returned an error: NotFound"...

Please help me...

Jav replied on Thursday, July 19, 2012

JonnyBee
Normally, you will set the startup project to the website that host the Silverlight container.

What if in your program you cannot go straight to the SL project. In other words, what if the user needs to select an item - a person perhaps - from a list before going over to the SL project.

I have had my project working just fine for months, but now suddenly I am getting the same error (but only when the project is istalled on the Server - it works fine when using /localhost:). I do have both, the clientaccesspolicy AND the crossdomainpolicy files in the project.

Jav replied on Friday, July 20, 2012

Finally found a solution - in other words discovered what I was doing wrong and what I was not doing at all.  Thought I'll share since the problem is commonplace.

1.  I had both, the ClientAccessPolicy AND the CrossDomainPolicy files in the project - it turns out only one is needed, so  now I only have one: ClientAccessPolicy

2. Just about every person answering forum messages offers the following ClientAccessPolicy

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

3.  Woudn't that be like saying to every thief, robber and scoundrel to "Just Come On In - the door is open".  After suffering through days of frustration, if this file makes things work, people like me are not ever going to mess with it - lest it breaks again.

Here's what I have now:

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

Of course  xxx.WebsiteName.xxx is the name of your website. You are blocking all access to your project except from your own site.
 

 4. It is probably not enough to just add this file to the root of your project.  I found a couple of authoritative voices suggest that this file be paced in: c:\Inetpub\wwwroot and that's what I did.
 
Since the problem in my case was always when I installed the project on the Server, so the c:\Inetpub\wwwroot is the folder on the Server.  As soon as I did that, it was like the sun came out.  My Internet Explorer stopped freezing, as it had done about 100 times (slight exageration) in the past 3 days, and everything has been working as it should.

Javed

 

Copyright (c) Marimer LLC