Guy Burstein's Blog

All about the newest tools and technologies from Microsoft

News

Guy Burstein
Work:
Microsoft Israel, 2 Hapnina st', Raanana
Israel
Email:
Or, use this form.
Guy Burstein The Bu

Disclaimer
Postings are provided 'As Is' with no warranties and confer no rights.

Guy Burstein LinkedIn Profile

TwitterCounter for @bursteg

The Bu

Links

Articles

Blogs I Read

Silverlight WCF Returns HTTP 404

Silverlight WCF Returns HTTP 404

Silverlight WCF HTTP 404 Today I ran into something weird. I created a WCF Service and tested it with simple .Net client application and it worked fine. Than, I build a Silverlight application and tried to call the same service, but kept getting: System.ServiceModel.ProtocolException: "The remote server returned an unexpected response: (404) Not Found."

What I found out was that since the WCF call was made to a service that is not under the same domain as my Silverlight application (or different ports in local development machine). This situation turns out to be a cross domain call, and Silverlight required the domain that hosts the WCF service to allow such calls. This can be done by placing a file called clientaccesspolicy.xml in the root directory of that domain.

So, in order to get your Silverlight make a successful call to a WCF service without getting HTTP 404 back, you should put the  clientaccesspolicy.xml in c:\inetpub\wwwroot\.

The file should look like:

<?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>

Of course, you should customize it according to your settings.

This is all it takes to get rid of Silverlight application WCF calls that returns HTTP 404

Enjoy!

Comments

No Comments