Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:29:31+00:00 2026-06-14T11:29:31+00:00

Our MVC3 routing engine has a couple entries which have a constraint which involves

  • 0

Our MVC3 routing engine has a couple entries which have a constraint which involves a database lookup to evaluate. For example:

        routes.MapRoute(
            "Product",
            "{manufacturer}/{partNumber}",
            new { controller = "Product", action = "Details", manufacturer = "" },
            new { manufacturer = new ManufacturerConstraint() }
        );
        routes.MapRoute(
            "Store",
            "{store}/{action}",
            new { controller = "Store", action = "Index" },
            new { store = new StoreConstraint() }
        );

where ManufacturererConstraint() involves a database lookup and StoreConstraint() does not.

We’re using RouteUrl to generate a link similar to:

RouteUrl("Product", new { manufacturer = product.Brand, partNumber = product.PartNumber });

Three questions from this:

  1. Does our usage cause a database lookup?
  2. If I generated a route for the “Store” route, would that also generate a lookup as it tests it against all routes? Or would it only do the one test for the specified route?
  3. If it does hit the database in this usage, is there a way to use RouteUrl that wouldn’t?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:29:33+00:00Added an answer on June 14, 2026 at 11:29 am

    Does our usage cause a database lookup?

    Yes, if the constraint is setup to work on UrlGeneration. Url.RouteUrl runs all constraints, just like Url.Action. The only difference is that you are explicitly saying which route you would like to use, instead of testing each route until one matches.

    If I generated a route for the “Store” route, would that also generate
    a lookup as it tests it against all routes? Or would it only do the
    one test for the specified route?

    I think I answered this above.

    If it does hit the database in this usage, is there a way to use
    RouteUrl that wouldn’t?

    Setup the constraint so it doesn’t run on UrlGeneration (using the routeDirection parameter). Personally, I’d cache the lookup data instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our server application runs as a service and has a ASP.NET MVC3 web-based frontend
I have an MVC3 C#.Net web app. We are using Aspose.Words to export our
We have recently upgraded from mvc2 to mvc3 and one of our Custom Authorization
We are using MVC3 and EF in our application. We are following Database First
I have an MVC3 view that's design to run reports for our clients. In
I have this route that worked before we upgraded our application to MVC3: routes.MapRoute(
In our new very large MVC3 application, we have a security problem to solve.
Here's our scenario: We have an MVC3 Application 'MVC3ABC' in solution S1 that is
We have a web service for our MVC3 app that communicates with our Oracle
To improve performance of our MVC3 application we want to mark some Controller's to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.