Silverlight Security Error when opening file

1. Run XML Data Binder and create a Silverlight project and sample application.
2. Copy an xml document into the root of the generated SampleApp.Web.
3. Run the project and enter the Uri of the XML document, e.g. http://localhost:1234/myxmldoc.xml.
4. Click Load XML and you see an error: Security error.
If you set a break point in MainPage.xaml.cs in method wc_OpenReadCompleted, you will be able to see the stack trace for the error:
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
   at System.Net.WebClient.OpenReadAsyncCallback(IAsyncResult result)
This is due to cross site script protection in IIS.
In a production environment, you should request your web site administrator assigns the correct authentication.
However, in order to quickly work around for your debug session, you can create a file named crossdomain.xml in the root folder of the SampleApp.Web project with the following contents:
<?xml version="1.0"?>
  <allow-http-request-headers-from domain="*" headers="*"/>
Note: This is only for debug purposes, you should not add this in a production environment.

Add Feedback