re: .NET Core: Use HttpClientFactory and Polly to build rock solid services VIEW POST


Though Polly provides it out-of-the-box with reasonable defaults, you don't need 3rd party libraries to reuse retry logic with HttpClient.
Just extract it to DelegatingHandler

public class RetryHandler : DelegatingHandler
    protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
        CancellationToken cancellationToken)
        /* your retry logic ... */

and then add it to DI:


Hi Dmitry,

Thank you very much for your comment, it is a very nice addition to the post.
It is always nice to have more options on the table!

code of conduct - report abuse