मैं सिल्वरलाइट को त्वरित नमूना एप्लिकेशन के साथ काम करने की कोशिश कर रहा हूं और एक अन्य कंप्यूटर पर एक बाकी सेवा कॉल कर रहा हूं। सर्वर है कि बाकी सेवा एक clientaccesspolicy.xml जो की तरह लग रहा है:सिल्वरलाइट रेस्ट सर्विस, सुरक्षा अपवाद
<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>
और उठाया जा रहा है (कम से कम नेटवर्क निशान मैं चलाने के अनुसार), और वहाँ crossdomain के लिए कोई अनुरोध है। एक्सएमएल। सी # कोड की तरह दिखता है:
public Page()
{
InitializeComponent();
string restUrl = "http://example.com/rest_service.html?action=test_result";
WebClient testService = new WebClient();
testService.DownloadStringCompleted += new DownloadStringCompletedEventHandler(testService_DownloadStringCompleted);
testService.DownloadStringAsync(new Uri(restUrl, UriKind.Absolute));
}
void testService_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
LoadTreeViewWithData(e.Result);
}
}
हालांकि, मैं हमेशा वापस निम्नलिखित सुरक्षा त्रुटि मिलती है:
{System.Security.SecurityException ---> System.Security.SecurityException: Security error. at System.Net.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.BrowserHttpWebRequest.c__DisplayClass5.b__4(Object sendState) at System.Net.AsyncHelper.c__DisplayClass2.b__0(Object sendState) --- End of inner exception stack trace --- at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result) at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)}
क्या मैं गलत कर रहा हूँ? और सुरक्षा त्रुटि मुझे कुछ और उपयोगी जानकारी क्यों नहीं बताती है?
इसे काम करने के लिए आपको क्या बदलना पड़ा? – stimms
जब आप सिल्वरलाइट प्रोजेक्ट एक वेब प्रोजेक्ट नहीं है तो आप बाकी सेवाओं को कॉल नहीं कर सकते हैं। –