Can I constrain a route parameter to a certain type in ASP.net MVC?

Posted by Paul Suart on Stack Overflow See other posts from Stack Overflow or by Paul Suart
Published on 2010-05-28T11:39:35Z Indexed on 2010/05/28 11:41 UTC
Read the original article Hit count: 262

Filed under:
|
|

I have the following route:

routes.MapRoute(
    "Search",                                               // Route name
    "Search/{affiliateId}",                                 // URL with parameters
    new { controller = "Syndication", action = "Search" }   // Parameter defaults
);

Is there a way I can ensure "affiliateId" is a valid Guid? I'm using MVCContrib elsewhere in my site and I'm fairly it provides a way to implement this kind of constraint.... I just don't know what it is!

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about routing