views:

59

answers:

1

Are there any performance issues with registering a number of routes with the routing engine in ASP.NET MVC 2? What I am planning on doing is registered one route per page for content pages that are not categories. In other words, for pages like this there would be one route registered for each one:

  • /Home/About
  • /Home/Contact
  • /Home/Directions
  • /Home/Meet-Our-Staff

While there are a number of these pages there aren't hundreds of them. Having an explicit route is useful because the third parameter to RoutCollection.MapRoute is "object defaults" and it can be used to hold some backend information related to the URL.

One alternative is to let requests for these URLs fall through to a default route which would do some lookups based on the URL (to get the same information as stored via "object defaults") and then follow the same code path to display the page. I prefer the first option as I think it is cleaner than parsing the URL and has performance advantages due to "object defaults".

+2  A: 

I do not know of any performance issues. URL routing is built to handle a large number of routes and I am pretty sure IIS compiles them once and uses them until the file that they are in is changed. You have to remember URL routing is built to handle catalogs where each product has it's own URL. So that should speak to its performance.

RandomBen