有一个需求如下:指定某个Area的路由(Area:Wx)在其后面添加用户名或者ID作为URL参数,即像下面的样子:
/Wx/xiaoming/
/Wx/xiaoming/photo
/Wx/xiaoming/photo/manage?oid=34
这样的话修改一下路由就好了,如下:
context.MapRoute( "Wx_rester_with_id2", "Wx/{rid}/{controller}/{action}/", new { controller = "Rester", action = "Index", rid = "" } );
获取参数的话正常获取就可以了,即:
public ActionResult Lili(long id) { var rid = this.RouteData.Values["rid"]; return Content("user yes:" + id); }