Q:

Specified method is not supported httpwebrequest - Silverlight

I am trying to use an HttpWebRequest object in Silverlight 2.0, to do a "POST".
Upon return from the BeginGetStream method I end up with the following error :
Message:    "Specified method is not supported."
StackTrace: "   at System.Net.BHWRAsyncResult.get_AsyncWaitHandle()"
Here's some sample code:  Note I have used fiddler to see if anything is being sent across the wire and there is no network activity.
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri("http://someurl"));
        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.Accept = "text/plain, */*";
        req.Headers["X-Requested-With"] = "XMLHttpRequest";

        AsyncCallback callBack = new AsyncCallback(streamResponse);

        req.BeginGetRequestStream(callBack, null);

Thanks,
Dave

A:

I just found one solution for this problem. HTTP Client need to know Content-Length to fill the Content-Length HTTP header value. Client can'not start request before it length became known. When You get RequestStream WebRequest can'not know how much bytes you will send to server. You must Close stream to commit Content-Length and only after closing the RequestStream You can call BeginGetResponse. It is strange that this not done inside WebRequest.
Hope this helps,
Dmitry

