7
我已經搜索堆棧的年齡,閱讀MSDN文檔和使用必應,但看不出爲什麼這不起作用!我已經獲得了相關的代碼+路線。名爲Browse
的路線工作得很好,但Details
路線的參數productCode
始終等於無。如果我做任何MODS我不斷收到'資源未找到'404頁面。ASP.NET MVC4路由問題
' 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}
)