I am trying to create a middleware that should execute after the execution of endpoint. But when I add middleware in after the app.UseEndPoints(), it never gets invoked, however it is invoked if placed before app.UseEndPoints(), but that invokes it before execution of endpoint.
I tried to create a middleware, I placed if after app.UseEndPoints() middleware in the Configure method in the Startup class and expected it to be invoked after the execution of the endpoint (Web APIs action method), but it did not get invoked.
// Logic Afterin Shahar's answer).