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)
         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}$" }
         "Default", // Route name
         "{controller}/{action}/{id}", // URL with parameters
         new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults

A big thanks to tobias!

One Response to “ASP.Net MVC3 Routing with Guid”

  1. search engine optimization

    I am not positive the place you are getting your info, however good topic.
    I must spend some time studying much more or understanding more.

    Thank you for fantastic information I used to be in search of this
    info for my mission.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>