【发布时间】:2012-06-21 23:38:23
【问题描述】:
我已经在 Stack 上搜索了很长时间,阅读了 MSDN 文档并使用了 Bing,但不明白为什么这不起作用!我在下面有相关代码+路线。名为Browse 的路由运行良好,但Details 路由的productCode 参数始终等于无。如果我制作任何模组,我会不断收到“找不到资源”404 页面。
' Lives in controller called 'Details'
' Usage: site.com/details/abc123
Function Index(productCode As String) As ActionResult
' Lives in controller called 'Browse'
' Usage: site.com/browse/scifi/2
Function Index(genre As String, Optional page As Integer = 1) As ActionResult
路线是:
routes.MapRoute( _
"Browse", _
"{controller}/{genre}/{page}", _
New With {.controller = "Browse", .action = "Index", .id = UrlParameter.Optional, .page = UrlParameter.Optional}
)
routes.MapRoute( _
"Details", _
"details/{productCode}", _
New With {.controller = "Details", .action = "Info", .productCode = UrlParameter.Optional}
)
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-routing asp.net-mvc-4