1
我有以下網址:ASP.NET MVC路由幫助
http://localhost/About
http://localhost/Contact
http://localhost/Shop
http://localhost/Shop/ListProducts/{CategoryID}/{CategoryName}
http://localhost/Shop/Checkout
http://localhost/Customer
http://localhost/Customer/Edit
http://localhost/Customer/ChangePassword
http://localhost/Authentication/LogOn
http://localhost/Authentication/LogOff
與以下地圖:
routes.MapRoute("Authentication", "Authentication/{action}", New With {.controller = "Authentication", .action = "Index"})
routes.MapRoute("Customer", "Customer/{action}", New With {.controller = "Customer", .action = "Index"})
routes.MapRoute("Shop", "Shop/{action}/{CategoryID}/{CategoryName}", New With {.controller = "Shop", .action = "Index", .CategoryID = UrlParameter.Optional, .CategoryName = UrlParameter.Optional})
routes.MapRoute("Main", "{action}", New With {.controller = "Main", .action = "Index"})
routes.MapRoute("Default", "{controller}/{action}/{id}", New With {.controller = "Main", .action = "Index", .id = UrlParameter.Optional})
雖然這似乎是工作,我需要一種方法來處理未知路線/網址與404.
我看過幾個樣本在這裏,並不能'讓他們工作。
另外,這些路線看起來不錯嗎?我在正確的軌道上嗎?
謝謝