A middleware nuget package for listing all routeable Razor components in an ASP.NET Core app.
Many thanks to Steve Smith (aka Ardalis) for his work on AspNetCoreStartupServices (from which I borrowed heavily to piece this together), and to Andrew Locke for his original post on the subject.
- Install NuGet package
PM> Install-Package Wrak.ListComponentRoutes
- Add the following to Startup's using statements:
using Wrak.ListComponentRoutes;
- Add the following at the bottom of Startup's
ConfigureServicesmethod:
services.AddListComponentRoutes(options =>
{
options.Path = "/my-custom-path"; // Optional - default path is '/routes'
options.Assemblies = new[] { typeof(Startup).Assembly };
});
- Add the following to Startup's
Configuremethod (in an if block so it only runs in Development)
if (env.IsDevelopment())
{
app.UseListComponentRoutes();
app.UseDeveloperExceptionPage();
}
If it's working you should see output like this listing all routeable Razor components in the configured assembly or assemblies:
