我想枚举我的应用程序中的所有路由,并获取它们的 URL。我怎样才能做到这一点?
最佳答案
也许尝试这样的事情:
List<string> ApplicationRoutes = new List<string>();
foreach (Route r in RouteTable.Routes)
ApplicationRoutes.Add(r.Url);
只是为了澄清,这只会为您提供 URL 模式,而不是实际的 URL。
关于asp.net-mvc - ASP.NET MVC : Get URLs to RouteTable Routes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6900475/