自定义路由在mvc 4中不起作用

时间:2014-08-19 20:33:30

标签: 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:61575/Exams/12/maharashtra+mba+common+entrance+test

但他的错误是

The resource cannot be found

SingleExam代码

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" }
        );

我做错了什么?

0 个答案:

没有答案