0

Does anyone know if in .NET CORE it is possible to have server middleware which would repeat the request based on the response from the original request.

Is it possible in the outgoing response to send in another request?

[Update Clarification] - The scenario is that the client makes a request, the .NET Core Web API attempts to carry out the request, an error is returned, the server middleware detects the error and send the request back in again.

I could do this in the Web API controller, but would have to repeat it in each controller method. I'm also trying to avoid having a base controller.

Thanks

rideintothesun
  • 1,628
  • 2
  • 12
  • 29
  • Can you be a bit more specific about what you're are trying to achieve? Might be that this blog is useful for you: https://weblog.west-wind.com/posts/2019/Jun/03/Building-Live-Reload-Middleware-for-ASPNET-Core ? – Andrew Jun 27 '19 at 13:27
  • I'm confused. Do you want the server to repeat the actions which were taken in order to deal with the request, if the response to the request contains some value? Or are you looking to instruct the client to resend the request? – Jamie Taylor Jun 27 '19 at 13:56
  • Please edit and revise your question, as it is entirely unclear what you're looking for here. – Chris Pratt Jun 27 '19 at 14:07
  • https://github.com/App-vNext/Polly might be helpful to build your own modules with custom retry policies. – Artyom Ignatovich Jun 27 '19 at 15:43

1 Answers1

0

To solve this I just created a middle ware component and in the Invoke method I just wrapped the

await next(httpContext);

call in a Polly policy using ExecuteAsync

rideintothesun
  • 1,628
  • 2
  • 12
  • 29