在ASP.NET Core中,有没有办法查看Startup中定义的所有路由的列表?我们使用MapRoute扩展方法IRouteBuilder来定义路由.
我们正在迁移一个较旧的项目WebAPI项目.我们可以使用它GlobalConfiguration.Configuration.Routes来获得所有路线.
更具体地说,我们在动作过滤器中执行此操作.
public class MyFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext actionContext)
{
base.OnActionExecuting(actionContext);
// This no longer works
// var allRoutes = GlobalConfiguration.Configuration.Routes;
// var allRoutes = ???
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试调试路由问题,我不确定外部应用程序必须点击哪个 url 才能正确触发我的控制器。我只想把它们全部打印出来。
我发现在 ASP.NET Core 中获取所有注册的路由,但似乎没有一个答案在 Asp.net Core 3.0 中有效
我还找到了https://www.nuget.org/packages/AspNetCore.RouteAnalyzer,但它适用于 Core 2.0