我有一个像http://..../controller/details/abc_1234
这样的路线处理网址。我想将以下网址路由到上一个网址:
http://..../controller/abc/1234
以下代码似乎不起作用?
routes.MapRoute(
"abc",
"{controller}/abc/{id}",
new { controller = "controller", action = "Details", id = "abc_{id}" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "controller", action = "Details", id = UrlParameter.Optional }
);
答案 0 :(得分:2)
routes.MapRoute(
"abc",
"{controller}/{action}/{key}_{id}",
new { controller = "controller" }
);
你的行动如下:
public virtual ActionResult Details(string key, string id)
{
}
答案 1 :(得分:0)
Try this with a action called `abc`
routes.MapRoute(
"abc",
"{controller}/abc/{id}",
new { controller = "controller", action = "abc", id = "abc_{id}" }
);