Monthly Archives: June 2012

ASP.Net MVC3 Routing with Guid

Spent a couple of hours trying to get routing with a Guid to work for MVC3 without luck. Here is the solution: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”); routes.MapRoute(“FooRouteName”, “Controller/Action/{guidParam}”, new { controller = “PremiumManager”, action = “ActionViewImage” }, new { guidParam = @”^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$” } ); routes.MapRoute( “Default”, // Route name “{controller}/{action}/{id}”, // URL… Read more »