【发布时间】:2009-05-03 19:54:41
【问题描述】:
所有,我的情况是我有基本路线,加上其他一些简单的路线:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = 1}
);
所以以下网址有效:http://somesite.com/tags/index/1
但是,我的一些索引页面采用以下方式的 url 参数:
http://somesite.com/tags/index/1?when=lastmonth
如何使用 Html.RouteLink 链接到这个?
您不能添加“?”像这样在全局 asax 文件中路由:
routes.MapRoute("TagsWhen", "Tags/index/{id}?when={when}",
new {controller = "Tags", action = "Index", id = "", when = ""});
如果这条路线有效,我可以使用以下方法链接到它:
Html.RouteLink(string.Format("{0} ", link.Rating), "LinksWhen",
new {id=link.ReferenceId, when=Model.When})
但事实并非如此!所以我不确定如何使用 Html.RouteLink 生成http://somesite.com/tags/index/1?when=lastmonth
【问题讨论】:
标签: c# .net asp.net asp.net-mvc