5
我有一個名爲Registration
控制器和它的操作方法如下:不能在MVC映射路徑爲特定的控制器4
public JsonResult GetReqs(GridSettings gridSettings, int rt)
{
...//whatever
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
所以我增加了一個途徑,現在我RouteConfig.cs
是這樣的:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "RegReq",
url: "{Registration}/{GetReqs}/{rt}",
defaults: new { controller = "Registration", action = "GetReqs", rt = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
但是我無法訪問rt
參數和操作方法GetReqs
不叫(我把它斷點,但什麼也沒發生)。錯誤在哪裏?
編輯:鏈接例子我想:~/Registration/GetReqs/1
固定!非常感謝 – AminSaghi