我已经搜索了 Stack 很长时间,阅读了 MSDN 文档并使用了 Bing,但看不出为什么这不起作用!我在下面有相关代码+路线。调用的路由Browse
工作得很好,但路由的productCode
参数Details
总是等于没有。如果我制作任何模组,我会不断收到“找不到资源”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}
)