Asp.net mvc 3 ASP.NET MVC3复杂路由问题
我设置了以下默认路线,效果良好:Asp.net mvc 3 ASP.NET MVC3复杂路由问题,asp.net-mvc-3,routing,routes,Asp.net Mvc 3,Routing,Routes,我设置了以下默认路线,效果良好: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter def
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
下面是一个成功的路线示例:“/PositionDetail/Candidates/2”
这一切都很好,但我的问题是,我想建立一条更深入的路线。i、 e.“/PositionDetail/Candidates/2/GetMoreCandidates”和“/PositionDetail/Candidates/2/Resume/3”,其中简历将是我想要执行的另一个操作,3将是ID。注意:每个路由将加载一个新页面,而不是一些局部视图
我如何设置这样的东西,“位置细节”控制器是什么样子的 例如,对于第二个任务,它可能如下所示:
public ActionResult Resume(int CandidateID, int ResumeID)
{
return View();
}
在您的路线中:
routes.MapRoute(
"Resume", // Route name
"{controller}/Candidates/{CandidateID}/{action}/{ResumeID}", // URL with parameters
new { controller = "PositionDetail", action = "Resume", CandidateID = UrlParameter.Optional, ResumeID= UrlParameter.Optional }
);
对于第一个任务-相同的逻辑