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 932929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:44:57+00:00 2026-05-15T20:44:57+00:00

I have a route defined last in my ASP.Net MVC 2 app that will

  • 0

I have a route defined last in my ASP.Net MVC 2 app that will map old urls that are no longer used to the appropriate new urls to be redirected to. This route returns the action and controller that is responsible for actually performing the redirect and it also returns a url to the controller action which is the url to redirect to. Since the route is responsible for generating the new url to redirect to, it is calling the router to get the appropriate urls. This has worked just fine with .Net 3.5, but when I upgraded to .Net 4, the GetVirtualPath method throws a System.Threading.LockRecursionException: “Recursive read lock acquisitions not allowed in this mode.”. The following code resolves the problem but is pretty ugly:

public static string GetActionUrl(HttpContextBase context, string routeName, object routeValues)
    {
        RequestContext requestContext = new RequestContext(context, new RouteData());
        VirtualPathData vp = null;

        try
        {
            vp = _Routes.GetVirtualPath(requestContext, routeName, new RouteValueDictionary(routeValues));
        }
        catch (System.Threading.LockRecursionException)
        {
            var tmpRoutes = new RouteCollection();
            Router.RegisterRoutes(tmpRoutes);
            vp = tmpRoutes.GetVirtualPath(requestContext, routeName, new RouteValueDictionary(routeValues));
        }

        if (vp == null)
            throw new Exception(String.Format("Could not find named route {0}", routeName));

        return vp.VirtualPath;
    }

Does anybody know what changes in .Net 4 might have caused this error? Also, is calling a route from another route’s GetRouteData method just bad practice and something I should not be doing at all?

  • 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-05-15T20:44:58+00:00Added an answer on May 15, 2026 at 8:44 pm

    As you figured out, it is not supported to call a route in the global route table from within another route in the global route table.

    The global route table is a thread-safe collection to enable multiple readers or a single router. Unfortunately the code you have was never supported, even in .NET 3.5, though in some scenarios it may have coincidentally worked.

    As a general note, routes should function independent of one another, so I’m not sure what your scenario is here.

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

Sidebar

Related Questions

On my ASP.NET MVC 3 App, I have a route constraint defined like below:
If say I have a route that is defined like this: {books}/{*all} , then
Suppose I have defined route like that, context.MapRoute( Preview, /preview/{id}/{type}, new { controller =
I have the following route defined in my Global.asax (MVC 3 web project): routes.MapRoute(
I have a defined route that displays a dynamic page: page_show: url: /:domain_slug/:slug class:
I have a route defined as follows: (r'^edit/(\d+)/$', 'app.path.edit') I want to use the
I have a route defined like this: GET /question/:q_id controllers.Questions.viewQuestion(q_id: Long) Then in my
I have the following route's defined: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.MapRoute(
I have a route that is suppose to match something like this localhost:3000/site/admin and
I want to have a route that looks something like: www.abc.com/companyName/Controller/Action/Id However, all the

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.