I have created web service and i am calling from silverlight application.
I am getting Inner Exception like:
{System.Security.SecurityException ---> System.Security.SecurityException: Security error. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c_DisplayClassa.b_9(Object sendState) at System.Net.Browser.AsyncHelper.<>c_DisplayClass4.b_0(Object sendState) --- End of inner exception stack trace --- 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.DownloadBitsResponseCallback(IAsyncResult result)}
Stack Trace :
" at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)\r\n at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)\r\n at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)"
When I google this error :
I came to know that this is issue of cross domain url so i have to add clientaccesspolicy.xml and crossdomain.xml file under C:\inetpub\wwwroot.
still am getting same error:
Let me know how to fix this error.
Below code i have used:
System.Uri uri = new System.Uri("https://[localhost]/CustomerPortalService12/AddAccount/" + "AccountName");
var result = "";
try
{
var webClient = new WebClient();
webClient.DownloadStringCompleted +=webClient_DownloadStringCompleted;
webClient.DownloadStringAsync(uri);
}
catch (Exception ex)
{
var wtf = ex.Message;
}
}
}
void webClient_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e)
{
}