【发布时间】:2011-08-17 04:05:52
【问题描述】:
我有以下网址:
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 的未知路由/url。
我在这里查看了一些示例,但似乎无法使它们起作用。
另外,这些路线看起来正确吗?我在正确的轨道上吗?
谢谢
【问题讨论】:
标签: asp.net-mvc-3 routing