I got a custom routes created for 2 different actions in same controller:
routes.MapRoute(
name: "editEquivPack",
url: "equivpacks/{id}/{ecommerceid}",
defaults: new { controller = "EquivPacks", action = "Edit" }
);
routes.MapRoute(
name: "addEquivPack",
url: "equivpacks/add/{ecommerceid}",
defaults: new { controller = "EquivPacks", action = "Add" }
);
In a
URL.RouteURL("addEquivPack", ecommerceid = Model.EcommerceID)
it generates a correct URL:
http://localhost:53365/EquivPacks/Add/1
But when i try to navigate there, it sends me a error message:
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32, Int32)' in 'XXXXXXX.Controllers.EquivPacksController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
It seems that it executes Edit
action and not Add
action that is the action configured in route map.
How can i fix it?