C# EndGetRequestStream上的NotSupportedException 公共异步静态任务GetResponseAsync(此HttpWebRequest请求,字典发布) { var tcs=new TaskCompletionSource(); 尝试 { request.BeginGetRequestStream((arReq)=> { var stream=request.EndGetRequestStream(arReq);//抛出NotSupportedException writeMultipartObject(流、post); stream.Close(); 请求。开始响应((ar)=> { var response=request.EndGetResponse(ar); 设置结果(响应); },空); },空); } 捕获(例外我们) { SetException(we); } 返回等待任务; }
当我发布一些东西时,它不起作用= var stream=request.EndGetRequestStream(arReq)//抛出NotSupportedException 告诉我为什么?总计 System.NotSupportedException-->System.NotSupportedException:不支持指定的方法。 位于System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) 在System.Net.Browser.ClientHttpWebRequest.c_DisplayClasse.b_d(对象发送状态)中C# EndGetRequestStream上的NotSupportedException 公共异步静态任务GetResponseAsync(此HttpWebRequest请求,字典发布) { var tcs=new TaskCompletionSource(); 尝试 { request.BeginGetRequestStream((arReq)=> { var stream=request.EndGetRequestStream(arReq);//抛出NotSupportedException writeMultipartObject(流、post); stream.Close(); 请求。开始响应((ar)=> { var response=request.EndGetResponse(ar); 设置结果(响应); },空); },空); } 捕获(例外我们) { SetException(we); } 返回等待任务; },c#,windows-phone-8,C#,Windows Phone 8,当我发布一些东西时,它不起作用= var stream=request.EndGetRequestStream(arReq)//抛出NotSupportedException 告诉我为什么?总计 System.NotSupportedException-->System.NotSupportedException:不支持指定的方法。 位于System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyn
在System.Net.Browser.AsyncHelper.c_DisplayClass1.b_0(对象发送状态)中,我经历了类似的行为(仅在Windows Phone上),并通过显式处理您正在写入的流使其工作。 因此,尝试添加
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;
}
之前,以及
stream.Dispose()
在你
stream.Flush();
声明,看看这是否有帮助
显然,.Net中网络堆栈的行为因代码运行的平台而异,这是因为.Net framework是为每个平台“重新开发”的
我希望这有帮助
干杯,
Kristof.我也经历过类似的行为(仅在Windows Phone上),并通过显式处理您正在写入的流使其正常工作。 因此,尝试添加
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;
}
之前,以及
stream.Dispose()
在你
stream.Flush();
声明,看看这是否有帮助
显然,.Net中网络堆栈的行为因代码运行的平台而异,这是因为.Net framework是为每个平台“重新开发”的
我希望这有帮助
干杯,
Kristof.我也经历过类似的行为(仅在Windows Phone上),并通过显式处理您正在写入的流使其正常工作。 因此,尝试添加
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;
}
之前,以及
stream.Dispose()
在你
stream.Flush();
声明,看看这是否有帮助
显然,.Net中网络堆栈的行为因代码运行的平台而异,这是因为.Net framework是为每个平台“重新开发”的
我希望这有帮助
干杯,
Kristof.我也经历过类似的行为(仅在Windows Phone上),并通过显式处理您正在写入的流使其正常工作。 因此,尝试添加
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;
}
之前,以及
stream.Dispose()
在你
stream.Flush();
声明,看看这是否有帮助
显然,.Net中网络堆栈的行为因代码运行的平台而异,这是因为.Net framework是为每个平台“重新开发”的
我希望这有帮助
干杯,
Kristof.该方法类似于“GET”或“POST”,显然,服务器不支持您正在使用的方法,至少在该URL上不支持。该方法类似于“GET”或“POST”,显然,服务器不支持您正在使用的方法,至少在该URL上不支持。该方法类似于“GET”或“POST”,显然,服务器不支持您正在使用的方法,至少在该URL上不支持。该方法类似于“GET”或“POST”,显然,服务器不支持您正在使用的方法,至少在该URL上不支持。谢谢。这解决了我的一个类似问题。我在GetResponseAsync()中遇到此错误。根据您的提示,将流放入using块解决了问题。谢谢。这解决了我的一个类似问题。我在GetResponseAsync()中遇到此错误。根据您的提示,将流放入using块解决了问题。谢谢。这解决了我的一个类似问题。我在GetResponseAsync()中遇到此错误。根据您的提示,将流放入using块解决了问题。谢谢。这解决了我的一个类似问题。我在GetResponseAsync()中遇到此错误。根据您的提示,将流放入using块解决了问题。