8
.NET Compact Framework上で非同期HTTP(S)POSTを実行しようとしていますが、動作しないようです。.NET Compact FrameworkのPOSTパラメータを使用した非同期WebRequest
は、ここで私がやっているものです:
private void sendRequest(string url, string method, string postdata) {
WebRequest rqst = HttpWebRequest.Create(url);
CredentialCache creds = new CredentialCache();
creds.Add(new Uri(url), "Basic", new NetworkCredential(this.Uname, this.Pwd));
rqst.Credentials = creds;
rqst.Method = method;
if (!String.IsNullOrEmpty(postdata)) {
rqst.ContentType = "application/xml";
byte[] byteData = UTF8Encoding.UTF8.GetBytes(postdata);
rqst.ContentLength = byteData.Length;
using (Stream postStream = rqst.GetRequestStream()) {
postStream.Write(byteData, 0, byteData.Length);
postStream.Close();
}
}
((HttpWebRequest)rqst).KeepAlive = false;
rqst.BeginGetResponse(DataLoadedCB, rqst);
}
private void DataLoadedCB(IAsyncResult result) {
WebRequest rqst = ((WebRequest)(((BCRqst)result.AsyncState).rqst));
WebResponse rsps = rqst.EndGetResponse(result);
/* ETC...*/
}
を...しかし、何らかの理由で私はDataLoadedCBの2行目のWebExceptionを取得:
「この要求は、認証のためのデータのバッファリングを必要としますか、リダイレクトを成功させることができます。
シンプルなHTTP GETを実行すると完全に同じコードが動作しますが、いくつかのPOSTパラメータを投げるとすべてが失敗します。
アイデア?
私はあなたがこの近く**((HttpWebRequestの)RQST)を追加することを意味推測.KeepAlive = falseは、**を:) –