是否可以在MVC中定義一個根據部分路徑動態解析動作的路由?在MVC 4.0中實現動態行爲的路線
public class PersonalController
{
public ActionResult FriendGroup()
{
//code
}
public ActionResult RelativeGroup()
{
//code
}
public ActionResult GirlFriendGroup()
{
//code
}
}
我想實現一個路由我的集團行動方法如下
Url: www.ParlaGroups.com/FriendGroup
www.ParlaGroups.com/RelativeGroup
www.ParlaGroups.com/GirlFriendGroup
routes.MapRoute(
"Friends",
"/Personal/{Friend}Group",
new { controller = "Personal", action = "{Friend}Group" }
);
routes.MapRoute(
"Friends",
"/Personal/{Relative}Group",
new { controller = "Personal", action = "{Relative}Group" }
);
routes.MapRoute(
"Friends",
"/Personal/{GirlFriend}Group",
new { controller = "Personal", action = "{GirlFriend}Group" }
);
我該怎麼辦上述路由實現?
這是路由101討好文檔:http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp- net-mvc-routing-overview-cs – 2014-09-10 13:08:21