我正在尝试创建一个看起来像这样的路线
site.com/controller/ {参数1} / {DBID} - {友好名称}
并省略默认操作索引,并且操作编辑位于网址末尾,如此
site.com/controller/ {参数1} / {DBID} - {友好名称} /编辑
路线对我来说有点混乱,所以任何帮助都表示赞赏, 谢谢!
答案 0 :(得分:1)
你可以尝试这样:
routes.MapRoute(
"SomeRoute",
"{controller}/{param1}/{dbID}-{friendlyName}/{action}",
new
{
controller = "home",
action = "index",
param1 = "CANNOT BE OPTIONAL",
dbID = "SOME DEFAULT ID",
friendlyName = "SOME DEFAULT FRIENDLY NAME"
}
);