title: WebClient doesn't connect to IHttpHandler
body: <p>I made my program according to example <a href="http://www.c-sharpcorner.com/UploadFile/nipuntomar/FileUploadsilverlight03182009030537AM/FileUploadsilverlight.aspx" rel="nofollow noreferrer">1</a> that was made for .NET framework 2, but I converted it to .NET framework 3.5. How should I modify this code to make it working? How can I debug server side? Server side seems to work when I manually insert parameters to url, so problem must be in client side code.</p>
  
  <pre><code>private void UploadFile(string fileName, System.IO.Stream data)
  {
      UriBuilder ub = new UriBuilder("http://localhost:59491/receiver.ashx");
      ub.Query = string.Format("filename={0}", fileName);
  
      WebClient c = new WebClient();
      c.OpenWriteCompleted += (sender, e) =&gt;
      {
          PushData(data, e.Result);
          e.Result.Close();
          data.Close();
      };
      c.OpenWriteAsync(ub.Uri);
  }
  
  private void PushData(System.IO.Stream input, System.IO.Stream output)
  {
      byte[] buffer = new byte[4096];
      int bytesRead;
  
      while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
      {
          output.Write(buffer, 0, bytesRead);
      }
  }
  </code></pre>
  
  <p><a href="http://www.c-sharpcorner.com/UploadFile/nipuntomar/FileUploadsilverlight03182009030537AM/FileUploadsilverlight.aspx" rel="nofollow noreferrer">1</a> <a href="http://www.c-sharpcorner.com/UploadFile/nipuntomar/FileUploadsilverlight03182009030537AM/FileUploadsilverlight.aspx" rel="nofollow noreferrer">http://www.c-sharpcorner.com/UploadFile/nipuntomar/FileUploadsilverlight03182009030537AM/FileUploadsilverlight.aspx</a></p>