0

I need to iterate over the the Http route table from the ASP.NET Web API from within an ASP.NET MVC Controller action method in the same project. All the routes work fine. I've been playing around with the HttpRouteCollection but its always empty.

I've been trying things like this: -

var httpRoutes = new IHttpRoute[10];
new HttpRouteCollection().CopyTo(httpRoutes, 0); 

foreach (var route in httpRoutes)
{
  // ...
}

Or this : -

var httpRoutes = new IHttpRoute[10];
new HttpRouteCollection("api/").CopyTo(httpRoutes, 0); 

foreach (var route in httpRoutes)
{
  // ...
}

How do I get to this info?

4

1 回答 1

0

您不应该访问 HttpRoutecollection 的 Global.Configuration.Routes 实例而不是创建一个新实例吗?

于 2013-04-30T23:57:17.140 回答