How to manage routing in large asp.net mvc projects

What are some strategies for managing URL routing in a large (100+ controller and growing) MVC project? The areas were useful, but their usefulness seems limited because they cannot nest. As the project grew, I noticed several big pain points:

  • SEO friendly routes (a special definition is required for each seo route)
  • Redirection for legacy routes (requires 301 old URL for updated equivalents)
  • Route testing (is there anything better than manual testing and easier than selenium?)

Also, does performance not deteriorate as the number of routes increases? The route determination method assumes that the performance is minimal O(n*k) , where n is the number of specific routes and k is the length in the URL.

+4
source share
1 answer

A few points to consider that might make this easier for you:

  • Are there any common features between the controllers?
  • Is there a way to create a common template for your controller and use some of the events raised by the controller to provide common functions (i.e. pulling data from the database into a serial template)?
  • What is fundamentally different between each controller?

The reason for these questions is that I see a couple of possible solutions:

  • Assuming you are running on IIS 7 or higher, you can split your functionality into multiple MVC projects for each area. It gets a lot easier with IIS 7 and above (for deployments that are).
  • Assuming a consistent presentation structure for your data, a common controller or route can make this a lot easier, allowing you to collapse your controllers.
  • A basic controller allows you to use sharing functions, providing the specialization required for each individual controller.

In general, I would recommend trying to split your code base into several MVC projects, based on the goal, to help establish this sense of sanity that seems to elude as your project continues to grow.

+2
source

All Articles