Asp.net mvc 自定义路由在mvc 4中不起作用
我已经创建了一条自定义路线Asp.net mvc 自定义路由在mvc 4中不起作用,asp.net-mvc,asp.net-mvc-4,asp.net-mvc-routing,custom-routes,Asp.net Mvc,Asp.net Mvc 4,Asp.net Mvc Routing,Custom Routes,我已经创建了一条自定义路线 routes.MapRoute("Exams", "Exams/{id}/{name}", new { controller = "Exam", action = "SingleExam", id = "", name = (string) null }, new[] { "MockTests.FrontEnd.Controllers" } ); 为此,我创建链接作为 http://localhost:615
routes.MapRoute("Exams",
"Exams/{id}/{name}",
new { controller = "Exam", action = "SingleExam", id = "", name = (string) null },
new[] { "MockTests.FrontEnd.Controllers" }
);
为此,我创建链接作为
http://localhost:61575/Exams/12/maharashtra+mba+common+entrance+test
但他的错误是
The resource cannot be found
单一考试代码
public ActionResult SingleExam(int id,string name)
{
return View();
}
其他路线
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "User", action = "Register", id = UrlParameter.Optional },
new[] { "MockTests.FrontEnd.Controllers" }
);
我做错了什么?发布你的单一考试操作代码,你可以显示路由表的其余部分吗?还添加了其他代码,你应该在默认路由之前的路由顶部添加此路由。你确定控制器的名字是考试而不是考试吗?欢迎你,我的朋友。我失去了一个公认的答案:)