views:

24

answers:

4

I'm having issues with cross domain access from a Silverlight project to a WCF service in ASP.

This tutorial recommends making crossdomain.xml or clientaccesspolicy.xml files and putting them in the web root of the service.

I have made these files, and put them in the top level of the project in Visual Studio. I'm still having the problem. Does that mean that I have the files in the wrong place?

clientaccesspolicy.xml:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM 
    "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt;
<cross-domain-policy>
  <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

crossdomain.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 include-subpaths="true" path="/"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

Update: I'm currently just working on the development server. How can I make it work there?

A: 

As far as I know they have to go in the root directory of the web server ( / ) and not the root of your web project.

larsw
what if I'm using the development server?
Rosarch
A: 

These files must be deployed along with the WCF service on the IIS web-server.

So the "root" is not the one of your project but the one of the web-site (in the sense of a IIS web-site).

Serious
how can I make that work locally?
Rosarch
If your service is running locally and the Silverlight client too you should not have any problems. Are the two bound to "localhost" ?
Serious
Ok, perhaps I'm mistaken about the cause of my problem. I've opened a new question.
Rosarch
A: 

One problem you end up with using the developement web server is that the web project holding your WCF service may well specify a virtual path. This places what appears at the root of the project in a virtual folder down from the "/" root from the clients perspective. Hence placing a clientaccesspolicy.xml file at the root of your project doesn't put the file at "/clientaccesspolicy.xml" where the silverlight client will expect it to be.

In Visual Studio open the properties window for the web project hosting you WCF services, select the Web tab, set the Virtual Path to "/". (You probably want to do that before you create the references and proxies to it in the Silverlight project).

BTW unless you intend to support client technologies other than Silverlight you do not need the crossdomain.xml file.

AnthonyWJones
I have already set the virtual path to `/`. I suspect that my problem is caused by something else; I've created a new question.
Rosarch
A: 

My files were in the right place. The problem is that the names of those two files were swapped - the SL cross domain rules were named with the Flash file name, and vice versa.

Rosarch