Skip to content

wrakocy/ListComponentRoutes

Repository files navigation

NuGet NuGet Build Status

ListComponentRoutes Middleware Package

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.

Getting Started

  1. Install NuGet package
PM> Install-Package Wrak.ListComponentRoutes
  1. Add the following to Startup's using statements:
using Wrak.ListComponentRoutes;
  1. Add the following at the bottom of Startup's ConfigureServices method:
services.AddListComponentRoutes(options =>
{                
    options.Path = "/my-custom-path"; // Optional - default path is '/routes'
    options.Assemblies = new[] { typeof(Startup).Assembly };
});
  1. Add the following to Startup's Configure method (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:

screenshot

About

A middleware package for listing all routeable Razor components in an ASP.NET Core app.

Resources

License

Stars

Watchers

Forks