title: Implement a retry policy in asp.net core
body: <p>What is the simplest way to implement a retry policy in asp.net core ? The idea is simple, if some particular type of exceptions is raised ( say sql deadlock ), we retry the httprequest for a maximum of N times.</p>
  
  <p>I use a middleware for som custom authentication, I don't know if a middleware is the best choice for this kind of mechanism ( I'm new to the pipeline architecture, I have read that there are several types of components : Singletons, per-request etc ..).</p>
  
  <p>UPDATE:
  Sql deadlock is given here just as an example, my application has only restful webservices in it, each request is very short and runs entirely in a Serializable Sql Transaction ( there is no other side effects which I can't rollback like sending email or deleting a File... ).
  Because I'm using transactions, and because I can't garantee that my transactions will always use the tables in the same order ( It depends on who calls the webservices ), deadlock is inavoidable, so I need to have a retry policy of all the httprequest.
  ( The question is not about transactions and deadlocks but how to implement a retry police in asp.net core )</p>