Reputation: 679
I got the following routes declared:
routes.MapRoute(
name: "SurveyContent",
url: "Survey/{action}/{id}",
defaults: new { controller = "Contents", action = "List", id = 3, type = 3 }
);
);
routes.MapRoute(
name: "ItemCreation",
url: "{controller}/Create",
defaults: new { controller = "Contents", action = "Details", id = 0 }
);
routes.MapRoute(
name: "OpenContent",
url: "Open/{code}",
defaults: new { controller = "Courses", action = "OpenContent", code = "" }
);
I am trying to access the link localhost/Survey/Create, but returns me a 404 error. Later on I added
routes.MapRoute(
name: "SurveyContent1",
url: "Survey/Create",
defaults: new { controller = "Contents", action = "Details", id = 0, type = 3 }
);
under the SurveyContent, but that didn't change anything. What am I doing wrong?
Upvotes: 2
Views: 461
Reputation: 18639
The route:
url: "Survey/{action}/{id}",
Will match Survey/Create
, before:
url: "{controller}/Create",
So place ItemCreation
before SurveyContent
.
In the route table, order matters.
Upvotes: 5