【发布时间】:2014-04-27 02:33:30
【问题描述】:
public async static Task<WebResponse> GetResponseAsync(this HttpWebRequest request, Dictionary<string, object> post)
{
var tcs = new TaskCompletionSource<WebResponse>();
try
{
request.BeginGetRequestStream((arReq) =>
{
var stream = request.EndGetRequestStream(arReq);//throw NotSupportedException
writeMultipartObject(stream, post);
stream.Close();
request.BeginGetResponse((ar) =>
{
var response = request.EndGetResponse(ar);
tcs.SetResult(response);
}, null);
}, null);
}
catch (Exception we)
{
tcs.SetException(we);
}
return await tcs.Task;
}
当我发布一些东西时,它不起作用..=.= var stream = request.EndGetRequestStream(arReq);//抛出 NotSupportedException 告诉我为什么? ToT........
System.NotSupportedException ---> System.NotSupportedException:不支持指定的方法。 在 System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) 在 System.Net.Browser.ClientHttpWebRequest.c_DisplayClasse.b_d(Object sendState) 在 System.Net.Browser.AsyncHelper.c_DisplayClass1.b_0(Object sendState)
【问题讨论】:
-
该方法类似于“GET”或“POST”,显然,服务器不支持您正在使用的方法,至少不支持该 URL。
标签: c# windows-phone-8