1
votes

I've following url/route stucture with single controller "product" for a website with expected traffic medium to low.

  1. website.com/about
  2. website.com/faq
  3. website.com/feedback
  4. website.com/product-name
  5. website.com/product/list

For the 4th route, anything that follows "website.com/xyz", gets routed to "details" action.

public ActionResult Details(string name) { }

I want "product-name" to be first level citizen in website. So for any single segment route ( about, privacy etc), i've to add one route for each action before "product-name" route. In future there is possibility that i will add some more single segment routes like "website.com/newaction"

Product details & list are frequently used actions and since routes are evaluated in sequence, this might cause performance issues for frequent routes?

Am i doing it correctly ? Is there any better way ? Or evaluating 10 or so routes for each request to frequent action is ok for regular to low traffic website ?

1

1 Answers

0
votes

10 routes will not affect performance, so don't worry about that. The first three routes can be grouped into one (assuming they are all handled by HomeController):

routes.MapRoutes(null, "{action}", 
   { action = "Index", controller = "Home" },
   { action = "index|about|faq|feedback" });