0
votes

The following code is not working..

The WriteCallback never happens and checking fiddler and also

it never POST but does a GET

private void Upload() {
var ub = new UriBuilder(UploadUrl);
Debug.Text += "Requesting " + ub.Uri + "\n";
var webrequest = (HttpWebRequest)WebRequest.Create(ub.Uri);
webrequest.Method = "POST";
Debug.Text += "Method : " + webrequest.Method + "\n";
webrequest.BeginGetRequestStream(new AsyncCallback(WriteCallback), webrequest);
Debug.Text += "webRequested\n";
}

private void WriteCallback(IAsyncResult asynchronousResult)
{
Debug.Text += "WriteCallback\n";
}

gives me the : Requesting http://localhost:22792/receiver.ashx?filename=Unsaved (1).AVI&StartByte=0&Complete=False
Method : POST
webRequested

1
Why don't you simply use WebClient? - mmx
because it is simply easier to write a WeRequest to upload data Using silverlight - MarkKGreenway

1 Answers

0
votes

You don't have any code in WriteCallback to indicate that you're done processing the event. So, I'm assuming your Main function or thread is not waiting for the request to be completed. Please see the sample code in the following documentation:

In particular, look at the C# example and search for allDone which is a ManualResetEvent used by the Main method to wait until the callback signals completion.