我的应用程序中有这条唯一的路线:
routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = ""} );
这对以下网址很有用:
/BLAH/指数 /创造/创造 /细节/细节5
我想给最后一个添加文本,就像这样:
/blah/details/5/page title here或随便什么
所以我的问题是:
我的路线应该是什么样的? (或者如果它与路线没有任何关系……我该怎么做?)
MSDN链路: http://msdn.microsoft.com/en-us/library/cc668201.aspx
routes.MapRoute( "Default", "{controller}/{action}/{id}/{*allTheRest}", new { controller = "Home", action = "Index", id = "", allTheRest=""} );
函数签名应类似于
public ActionResult MyAction(int? id, string rest) { this.TempData["ID"] = id ?? -1000; this.TempData["REST"] = rest ?? "Not Provided"; return View(); }