Web Api + HttpClient: An asynchronous module or handler completed while an asynchronous operation was still pending

后端 未结 3 2038
悲哀的现实
悲哀的现实 2020-12-07 14:15

I\'m writing an application that proxies some HTTP requests using the ASP.NET Web API and I am struggling to identify the source of an intermittent error. It seems like a ra

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 14:44

    A slightly simpler model is that you can actually just use the HttpContents directly and pass them around inside the relay. I just uploaded a sample illustrating how you can rely both requests and responses asynchronously and without buffering the content in a relatively simple manner:

    http://aspnet.codeplex.com/SourceControl/changeset/view/7ce67a547fd0#Samples/WebApi/RelaySample/ReadMe.txt

    It is also beneficial to reuse the same HttpClient instance as this allows you to reuse connections where appropriate.

提交回复
热议问题