現(xiàn)在有這個(gè)需求,
Controller1:
? public ActionResult ShowRefusalDetails(string brxm, string zyhm, string groupName = "")
Controller2:
? ?public ActionResult Index(string brxm, string zyhm,string groupName="")
需要注冊(cè)路由實(shí)現(xiàn)路由訪問,已經(jīng)寫好了。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}",
defaults: new { controller = "SMSService", action = "Index" }
);
routes.MapRoute(
name: "Default1",
url: "{controller}/{action}/{brxm}/{zyhm}/{groupName}",
defaults: new { groupName = UrlParameter.Optional }
);
//上面這個(gè)模板,可以正常匹配到 2個(gè)不同 控制器的不同action,但前提 2個(gè)action參數(shù)必須一致,同名同數(shù)目。
}
問題來(lái)了,現(xiàn)在Controller1的第一個(gè)參數(shù)名字要改,改成?brxm666,那么 路由模板怎么修改?才能正常訪問這2個(gè)action。
求正確代碼,謝謝!
MVC路由問題請(qǐng)教高手
月關(guān)寶盒
2018-12-07 02:16:59