Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 自定义路由在mvc 4中不起作用_Asp.net Mvc_Asp.net Mvc 4_Asp.net Mvc Routing_Custom Routes - Fatal编程技术网

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

我做错了什么?

发布你的单一考试操作代码,你可以显示路由表的其余部分吗?还添加了其他代码,你应该在默认路由之前的路由顶部添加此路由。你确定控制器的名字是考试而不是考试吗?欢迎你,我的朋友。我失去了一个公认的答案:)