7
Stack을 검색하여 MSDN 문서를 읽고 Bing을 사용했지만 왜 작동하지 않는지 알 수 없습니다. 아래에 관련 코드가 있습니다. Browse
이라는 경로는 정상적으로 작동하지만 Details
경로의 productCode
매개 변수는 항상 아무 것도 아닙니다. 개조를하면 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}
)