使用带有UWP应用程序的.Net标准2.0库时的HttpClient异常

时间:2018-05-21 07:46:18

标签: .net uwp .net-standard-2.0

我正在使用.Net标准库2.0,它使用HttpClient POST与REST端点进行通信。我正在使用client.SendAsyncHttpRequestMessage并等待通话。该库在UWP应用程序中引用,我正在调用POST方法以从REST端点获取响应。

我总是遇到以下异常,但未能找到任何有关此错误的线索或任何详细信息。请注意我运行它的机器在网络中,我可以通过浏览器访问REST端点。此外,UWP应用程序还启用了所有必要的功能(互联网,客户端/服务器)。

使用Visual Studio 2017与OS目标版本16299 Build(秋季创作者更新)

有没有人遇到类似问题?

异常详细信息:

ex = {System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Runtime.InteropServices.COMException: The text associated with this error code could not be found.
A connection with the server could not be established
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  ... at System.Net.Http.HttpClientHandler.d__111.MoveNext()
  --- End of stack trace from previous location where exception was thrown - --
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.Net.Http.HttpClient.d__58.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
  at HttpTest.Client.d__11.MoveNext()

谢谢你, 阿克沙伊。

0 个答案:

没有答案