我宣布了以下路线:
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 = "" }
);
我正在尝试访问 localhost / Survey / Create 链接,但返回404错误。后来我添加了
routes.MapRoute(
name: "SurveyContent1",
url: "Survey/Create",
defaults: new { controller = "Contents", action = "Details", id = 0, type = 3 }
);
在SurveyContent下的,但这并没有改变任何事情。我做错了什么?
答案 0 :(得分:5)
路线:
url: "Survey/{action}/{id}",
匹配Survey/Create
,之前:
url: "{controller}/Create",
所以请ItemCreation
之前放置SurveyContent
。
在路线表中,订单很重要。