MVC route with id and sub-action
- by Dan Revell
I can't figure out what I need to do with MVC routing to make this work
Here's my one route:
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{id}/{action}",
defaults: new { id = RouteParameter.Optional, action = RouteParameter.Optional }
);
The request /Shipments/ works great.
The request /Shipments/3/Packages works great.
The request /Shipments/3 however fails with the error:
Multiple actions were found that match the request:
System.Linq.IQueryable`1[Api.Controllers.RequisitionsController+PackageRequisitionWithTracking]
GetPackageRequisitions(Int32) on type
Api.Controllers.RequisitionsController Api.Models.ShipmentRequisition
GetShipmentRequisitions(Int32) on type
Api.Controllers.RequisitionsController
It can't seem to differentiate between:
public ShipmentRequisition GetShipmentRequisitions(int id)
and
[ActionName("Packages")]
public IQueryable<PackageRequisitionWithTracking> GetPackageRequisitions(int id)
I would have thought the lack of action name on the get shipment by id would allow that route to work.