我打算在 ASP .NET MVC3 中注册如下路由:
routes.MapRoute(
"SearchRoute", // Route name
"Report/Search/{code}/{quarter}/{year}/{receivedBegin}/{receivedEnd}/{transactionBegin}/{transactionEnd}/{page}", // URL with parameters
new {
controller = "Report",
action = "Search",
page = UrlParameter.Optional } // Parameter defaults
);
该路由将链接到名为 Report 的控制器中的此函数:
public ActionResult Search(string code, int? quarter, int? year,
DateTime? receivedBegin, DateTime? receivedEnd,
DateTime? transactionBegin, DateTime? transactionEnd, int? page=1)
我预计 Html.ActionLink 生成的指向该函数的链接将生成如下:Report/Search/10/2/2012/04-30-2012/04-01-2012/04-30-2012
当我使用 Html.ActionLink 生成链接时,生成的链接如下:
Report/Search?code=100&quarter=2&year=2012&receivedBegin=04-01-2012&receivedEnd=04-30-2012&transactionBegin=04-01-2012&transactionEnd=04-30-2012
我应该怎么做才能产生预期的结果?谢谢你。
更新
这是我用来创建链接的代码:
@Html.ActionLink("First", "Search", new {
code = currentCode,
quarter = currentQuarter,
year = currentYear,
receivedBegin = currentReceivedBegin,
receivedEnd = currentReceivedEnd,
transactionBegin = currentTransactionBegin,
transactionEnd = currentTransactionEnd }, null).