Skip to content

dogguts/AspNetCore.DisplayRoutes

Repository files navigation

AspNetCore.DisplayRoutes

View route information for AspNetCore projects.
Given that routes are registered with the (new since 3.0) AspNetCore IEndpointRouteBuilder (aka convention based), like below;

  app.UseEndpoints(endpoints => { ...

or through the usual route-related Attributes (aka attribute based);

    [Area("Dashboard")]
    [Route("[area]/{collectionId?}/[controller]/[action]/{id?}")]
    public class GridController : Controller {
    ...

Packages

Stable CI
AspNetCore.DisplayRoutes NuGet GPR

Screenshot

Screenshot

Usage

AspNetCode.DisplayRoutes can add an additional route to your application where, when visited, will report all registered routes in your application.

Add a reference to the AspNetCore.DisplayRoutes nuget package in your (web) project:

#Package manager
Install-Package AspNetCore.DisplayRoutes

or

#CLI
dotnet add package AspNetCore.DisplayRoutes

For more options see NuGet

Register PrintRoutes route

Create an additional route using the default/predefined options;

public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
  ...  
  app.UseEndpoints(endpoints => {
    ...  
    endpoints.PrintRoutes();
    ...  

Or override default options;

public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
  ...  
  app.UseEndpoints(endpoints => {  
    ...  
    endpoints.PrintRoutes(o => {
        o.Renderer = new AspNetCore.DisplayRoutes.Render.HtmlRenderer();
        o.Pattern = "/myroutes";
    });
    ...  

Options

Option Default
Pattern The route path where the route report will be provided /routes
HttpMethods Allowed HTTP methods for the registered route path ["GET"]
Renderer The format the routes will be presented UnicodeBoxRenderer

Renderers

ContentType
AsciiBoxRenderer AsciiBoxRenderer text/plain; charset=UTF-8
HtmlRenderer HtmlRenderer text/html; charset=UTF-8
JsonRenderer JsonRenderer application/json
UnicodeBoxRenderer UnicodeBoxRenderer text/plain; charset=UTF-8

About

View route information in AspNetCore (>=3.0) projects.

Resources

Stars

Watchers

Forks

Languages