AnthonySteele / MvcRouteTester

A library for unit testing ASP MVC route tables for both Web and API Routes
Apache License 2.0
105 stars 43 forks source link

Attribute routing with multiple verbs on the same route #37

Closed AnthonySteele closed 10 years ago

AnthonySteele commented 10 years ago

When using attribute routing, and a controller has two action methods with different names which handle the same route for different http verbs, there is one resulting route of type RouteCollectionRoute, which internally contains the two routes to the action methods. Or more routes if there are more verbs.

e.g.

public class FooController : Controller
 {
    [Route("foo")]
    [HttpGet]
    public ActionResult Get()
    {
      .... 
    }

    [Route("foo")]
    [HttpPost]
    public ActionResult Post()
    {
      .... 
    }
 }

But I haven't yet found a way of working out yet which of the contained routes is actually matched, and so what the actual action method name is.

I'm a bit puzzled by the design choice of having a RouteCollectionRoute. When routing, you have a route collection, then you resolve the route for a url by calling GetRouteData. Now you have one route. But if it's a RouteCollectionRoute so it's actually multiple routes. So route resolution isn't over yet. What's been gained by having a RouteCollectionRoute?

AnthonySteele commented 10 years ago

Sent this query to SO: http://stackoverflow.com/questions/22416561/finding-the-right-route-in-a-routecollectionroute

iachernov commented 8 years ago

@AnthonySteele ,

The issue is fixed in muster branch but has not merged to other branches like MVC5_1. So it is unable to use the fixed version via nuget package. Are you planing to update nuget with this and other fixes?