Yes, this experience needs to be improved since the exception is ignored.
For your above scenario, you will need to infer from the HttpMessageHandler instead of the DelegatingHandler , as the delegation handler will try to delegate the request to the handlers after it (example: exception mentioned Message=The inner handler has not been assigned )
For example, the following will work:
appBuilder.UseHttpMessageHandler(new MyNonDelegatingHandler()); public class MyNonDelegatingHandler : HttpMessageHandler { protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { HttpResponseMessage response = new HttpResponseMessage(); response.Content = new StringContent("Hello!"); return Task.FromResult<HttpResponseMessage>(response); } }
And to create a chain of handlers, you can do the following:
appBuilder.UseHttpMessageHandler(HttpClientFactory.CreatePipeline(innerHandler: new MyNonDelegatingMessageHandler(), handlers: new DelegatingHandler[] { new DelegatingHandlerA(), new DelegatingHandlerB() }));
source share