How do I get a list of active middlewares? How do I get a list of middlewares for specific url (each url may have a different set of middlewares added to the pipeline)?
I would like to know which middlewares are being added by using some of the common builder extensions like UseMvc()
or app.UseIdentity();
I know I could check the source code of each extension. Is there a runtime method to get this?
No, you can't. When you add a middleware to the pipeline, it's resolved to a Func<RequestDelegate, RequestDelegate>
. The components are saved in a private field in the ApplicationBuilder
implementation. You could however bake an extension method with some reflection magic to determine the actual middleware type, but it's not trivial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With