Asp.net mvc 3 ASP.NET MVC路由帮助

Asp.net mvc 3 ASP.NET MVC路由帮助,asp.net-mvc-3,routing,Asp.net Mvc 3,Routing,我有以下url: 以及下列地图: routes.MapRoute("Authentication", "Authentication/{action}", New With {.controller = "Authentication", .action = "Index"}) routes.MapRoute("Customer", "Customer/{action}", New With {.controller = "Customer", .action = "Index"}) route

我有以下url:

以及下列地图:

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的方法

我看了这里的一些样品,似乎不能使它们起作用

还有,这些路线看起来对吗?我走对了吗


谢谢

您的思路正确-请参阅此帖子以处理所有404

特别是这一部分

routes.MapRoute( "404-PageNotFound", "{*url}", new { controller = "StaticContent", action = "PageNotFound" } ); routes.MapRoute( “404页未找到”, “{*url}”, 新建{controller=“StaticContent”,action=“PageNotFound”} ); routes.MapRoute( "404-PageNotFound", "{*url}", new { controller = "StaticContent", action = "PageNotFound" } );