0
我正在Web站點項目(而不是Web應用程序)中工作,Web窗體和MVC愉快地生活在一起。爲了組織我的代碼,我試圖設置具有MVC部分的區域,並且正在遇到這種情況。在RouteConfig中工作的相同路徑,但不是AreaRegistration
我設置我與控制器區域和我創建以下區域配置:
Namespace Areas.Awesome
Public Class AwesomeAreaRegistration
Inherits AreaRegistration
Public Overrides ReadOnly Property AreaName As String
Get
Return "Awesome"
End Get
End Property
Public Overrides Sub RegisterArea(context As AreaRegistrationContext)
context.MapRoute(
"Awesome_default",
"Awesome/{controller}/{action}/{id}",
New With {.controller = "Sauce", .action = "Index", .id = UrlParameter.Optional},
New String() {"Areas.Awesome"}
)
End Sub
End Class
End Namespace
當我嘗試導航到/Awesome/Sauce/
我得到一個404錯誤,我的網站實際上是嘗試的路線我/Awesome/Sauce/Default.aspx
。
然而,當我移動的路線我RouteConfig
:
Public Module RouteConfig
Public Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}")
routes.MapRoute(
"Awesome_default",
"Awesome/{controller}/{action}/{id}",
New With {.controller = "Sauce", .action = "Index", .id = UrlParameter.Optional},
New String() {"Areas.Awesome"}
)
End Sub
End Module
這起到了/Awesome/Sauce/
預期。
我做了一些挖掘並同時創建了兩個路由,但使用不同的URI,我發現它們都以相同的方式定義,但一個正在工作,另一個不是。
有什麼我失蹤的區域註冊會導致這些路由被忽略,而在RouteConfig中定義的路由不是?