Search code examples
c#asp.net-coremiddleware

How can I get a list of registered middleware in ASP.NET Core?


In ASP.NET Core, you can register new middleware into the request processing pipeline during the Configure method of the startup class you're using for your web host builder by using app.UseMiddleware(...). During debugging, how do I get a list of registered middleware providers, though? I can't see any way to actually view the middleware that's been registered for the app.


Solution

  • From another question that someone's pointed out is very similar to this one:

    The list of middleware is not publically available, for some reason. In debug mode, though, it is available by examining the IApplicationBuilder app variable during execution of the Configure method, specifically the _components non-public member. This non-public member is an IList<Func<RequestDelegate, RequestDelegate>>, containing a list of entries representing the middlewares that have been registered so far.