title: Using WebClient to download string from ASP.NET Web Service Error
body: <p>I have a simple ASP.NET Web Service:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Web;
  using System.Web.Services;
  using System.Web.Script.Services;
  using System.Web.Script.Serialization;
  using System.Web.UI.WebControls;
  using System.Web.UI;
  
  namespace WebService1
  {
      /// &lt;summary&gt;
      /// Summary description for Service1
      /// &lt;/summary&gt;
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      [ScriptService]
      public class Service1 : System.Web.Services.WebService
      {
          [WebMethod]
          [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
          public string Get()
          {
              member mem = new member();
              mem.hello = "hello hello hello";
              mem.kalon = "fafasdf";
              mem.name = "wfasdfawe";
              return new JavaScriptSerializer().Serialize(mem);
          }
  
          [WebMethod]
          public string HelloWorld()
          {
              return "Hello World";
          }
      }
  
      public class member
      {
          public string hello { get; set; }
          public string name { get; set; }
          public string kalon { get; set; }
      }
  }
  </code></pre>
  
  <p>I'm facing problem to retrieve the string from SilverLight by using WebClient. Can you enlighten me? I uses the below code to get the string from the WebService.</p>
  
  <pre><code>WebClient wc = new WebClient();
  
  public MainPage()
  {
      InitializeComponent();
      wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
  }
  
  private void button1_Click(object sender, RoutedEventArgs e)
  {
      Uri uri = new Uri("http://www.MyWeb.com/Service1.axms/Get");
      wc.DownloadStringAsync(uri);
  }
  
  void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
  {
      MessageBox.Show(e.Error.ToString());
      MessageBox.Show(e.Result);
  }
  </code></pre>
  
  <p>And I receive error:</p>
  
  <p>System.Security.SecurityException ---> System.Security.SecurityException: Security error.
     at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
     at System.Net.Browser.BrowserHttpWebRequest.&lt;>c_<em>DisplayClass5.b</em>_4(Object sendState)
     at System.Net.Browser.AsyncHelper.&lt;>c_<em>DisplayClass4.b</em>_1(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)</p>
  
  <p>I have tried this too, still getting the same error:</p>
  
  <pre><code>Uri uri = new Uri("http://www.MyWeb.com/Service1.axms?op=Get");
  wc.DownloadStringAsync(uri);
  </code></pre>
  
  <p>1 more question:
  Is the url like this correct to get the string?</p>
  
  <pre><code>http://www.MyWeb.com/Service1.axms?op=Get
  
  http://www.MyWeb.com/Service1.axms/Get
  </code></pre>