Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.NET MVC Route Performance

I have an application with a couple thousand routes.

This is because for each product we use a custom URL, as opposed to the textbook /product/id.

With this many urls, the performance is unacceptable in the router.

I am trying to find ways to improve it, but I am drawing a blank.

I have about 20 regex routes and about 3 thousand unique url routes.

Any Ideas?

Sorry for being so open ended, but I am not sure where to start.

like image 730
hivie7510 Avatar asked Feb 02 '26 20:02

hivie7510


1 Answers

If your urls are all on the format yoursite.com/{url}, you can still store all the three thousand urls in the database, and create a custom controller factory which uses the {url} parameter to look the correct information up in the database and assign correct controller, action and any parameters you're using.

There are lots of posts on google on how to implement the controller factory.

I imagine you'll also want some parsing of the existing routes to put them all in the database - this can probably be done by iterating over the RouteTable after you instantiate your application (i.e. after RegisterRoutes() is called).

like image 161
Tomas Aschan Avatar answered Feb 04 '26 12:02

Tomas Aschan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!