webapi batching and delegating handlers

后端 未结 2 1059
走了就别回头了
走了就别回头了 2020-12-16 03:42

based on my last post I was able to get batching working... until a certain point. In addition to registering the route specific handler I also have 2 delegating handlers

2条回答
  •  清酒与你
    2020-12-16 03:58

    I've had this error without batching. I made an HttpClientFactory of my own and it takes in a HandlerFactory, also my own.

    It calls the HandlerFactory.Create() method in the constructor and stores the resulting handlers that it made.

    These are passed to the System.Net.Http.HttpClientFactory.Create(...) method whenever the factory needs to make a new HttpClient.

    But it's then only good for a single call because the handlers themselves are mutated by the .NET code leaving them in a state that means they cannot be reused.

    I altered my constructor so that it doesn't create the handlers up front, but each time. It now works.

提交回复
热议问题