如何在 ASP.NET MVC 中的 URL 后面允许额外文本?
我的应用程序中有这条唯一的路线:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = ""}
);
这对于以下 URL 非常有用:
/Blah/索引
/废话/创建
/废话/详细信息/5
我想像这样向最后一个添加文本:
/Blah/Details/5/Page-Title-Here-Or-Whatever
所以我的问题是:
我的路线应该是什么样子才能完成这个任务?(或者如果它与路线...我该怎么办?)
I have this sole route in my app:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = ""}
);
This works great for URLs like:
/Blah/Index
/Blah/Create
/Blah/Details/5
I want to add text to that last one like SO does:
/Blah/Details/5/Page-Title-Here-Or-Whatever
So my question is:
What should my routes look like to accomplish this? (or if it doesn't have anything to do with routes...what do I do?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MSDN 链接: http://msdn.microsoft.com/en-us/library /cc668201.aspx
函数签名应类似于
MSDN Link: http://msdn.microsoft.com/en-us/library/cc668201.aspx
Function signature should be similar to