Get all registered routes in ASP.NET Core

前端 未结 8 1389
独厮守ぢ
独厮守ぢ 2020-12-02 12:07

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 somethin

8条回答
  •  感情败类
    2020-12-02 12:43

    You are trying to get a router of type RouteCollection. To get all routes of that type you should be able to call .All() on routers of type RouteCollection.

    Example: var routes = RouteData.Routers.OfType().All();

    Credit to: https://rimdev.io/get-registered-routes-from-an-asp.net-mvc-core-application/

    Refer to above article if .All() doesn't work.

提交回复
热议问题