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}
)