I am new to .NET Core. I want to get a list of all registered routes in ASP.NET Core. In ASP.NET MVC we had route table in System.Web.Routing
, is there something equivalent in ASP.NET Core? I want to get the routes list in my Controller Action.
I've created the NuGet package "AspNetCore.RouteAnalyzer" that provides a feature to get all route information.
Try it if you'd like.
PM> Install-Package AspNetCore.RouteAnalyzer
using AspNetCore.RouteAnalyzer; // Add
.....
public void ConfigureServices(IServiceCollection services)
{
....
services.AddRouteAnalyzer(); // Add
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
....
app.UseMvc(routes =>
{
routes.MapRouteAnalyzer("/routes"); // Add
....
});
}
Run project and you can access the url /routes
to view all route information of your project.