我已经搜索了Stack多年,阅读了MSDN文档并使用了Bing,但是看不出为什么这不起作用!我在路线下面有相关的代码.名为Browse的路由工作得很好,但Details路由的productCode参数总是等于零.如果我制作任何mods,我会继续获得“找不到资源”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} )@H_301_8@