Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of middlewares in ASP.NET Core

Tags:

asp.net-core

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?

like image 295
mbudnik Avatar asked Aug 26 '15 19:08

mbudnik


1 Answers

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.

like image 148
Henk Mollema Avatar answered Nov 15 '22 08:11

Henk Mollema