Show current route info and all routes in an ASP.NET Core application
Inspired by .NET Framework version of the origional RouteDebugger: https://haacked.com/archive/2008/03/13/url-routing-debugger.aspx/
We need something similar in .NET Core, with a few differences:
- Add route info in response header instead of append them in HTML
- Use JSON over HTML table for better tooling support
- Use Middleware to make it .NET Corelish
dotnet add package Edi.RouteDebugger
Recommend use in development environment ONLY
If you are using the Developer Exception Page middleware, put this middleware BEFORE the call to
app.UseDeveloperExceptionPage()
as the exception page would not work otherwise.
if (env.IsDevelopment())
{
app.UseRouteDebugger();
}
You can also use an overload to specify custom path where the route debugger will be available, for example:
if (env.IsDevelopment())
{
app.UseRouteDebugger("/tools/route-debugger");
}
- Open any page in your application
- View response header
- Access
/route-debugger
or your custom path from browser or postman