我正在訪問採用不同數量參數的不同操作,但即使應用自定義路由,始終也會發生對相同操作的調用。 控制器數據-----使用自定義路由調用控制器操作始終指向相同的操作
[System.Web.Mvc.ActionName("Details1")]
public string Detail1(string Name)
{
return null;
}
[System.Web.Mvc.ActionName("Details2")]
public string Detail2(string Name, string secondName)
{
return null;
}
定製路由
context.MapRoute(
"M_default",
"controllername/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
context.MapRoute(
"name1",
"controllername/{Name}",
new { controller = "controllername", action = "Details1" }
);
context.MapRoute(
"name2",
"controllername/{Name}/{secondName}",
new { controller = "controllername", action = "Details2" }
);
的抗凍路由缺省,第二路由是詳情1,第三路線爲details2。
我調用這些從視圖$。員額,其網址是在 網址爲從詳情1 here
調用
"/api/controllername/?Name="+somename+"",
網址爲Details2調用
"/api/controllername/?Name="+somename+"&secondName="+othername,
我採取了參考什麼是可能的解決方案。任何建議,幫助將不勝感激。
我想以這種方式仍是結果是一樣的,我已經把路線順序details2,細節,默認路由後。 – user1260967 2013-03-26 16:54:00