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

  • Home
  • SEARCH
  • 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 6130267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:50:18+00:00 2026-05-23T16:50:18+00:00

I am trying to come up with an approach to create dynamic routing. What

  • 0

I am trying to come up with an approach to create “dynamic” routing. What I mean, exactly, is that I want to be able to assign the controller and action of a route for each hit rather than having it mapped directly.

For example, a route may look like this “path/{object}” and when that path is hit, a lookup is performed providing the appropriate controller / action to call.

I’ve tried discovering the mechanisms for creating a custom route handler, but the documentation / discoverability is a bit shady at the moment (I know, its beta – I wouldn’t expect any more). Although, I’m not sure if thats even the best approach and perhaps a controller factory or even a default controller/action that performs all of the mappings may be the best route (no pun intended) to go.

Any advice would be appreciated.

  • 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-23T16:50:18+00:00Added an answer on May 23, 2026 at 4:50 pm

    You can always use a catch all syntax ( I have no idea if the name is proper).

    Route:

    routeTable.MapRoute(
    "Path",
    "{*path}",
    new { controller = "Pages", action = "Path" });

    Controller action is defined as:
    public ActionResult Path(string path)

    In the action for controller you will have a path, so just have to spilt it and analyse.

    To call another controller you can use a RedirectToAction ( I think this is more proper way). With redirection you can set up a permanent redirectionfor it.
    Or use a something like that:

     internal class MVCTransferResult : RedirectResult
        {
            public MVCTransferResult(string url) : base(url) 
            {
            }
            public MVCTransferResult(object routeValues) 
                    : base(GetRouteURL(routeValues))
            {
            }
    
            private static string GetRouteURL(object routeValues)
            {
                UrlHelper url = new UrlHelper(
                    new RequestContext(
                            new HttpContextWrapper(HttpContext.Current),
                            new RouteData()),
                            RouteTable.Routes);
                return url.RouteUrl(routeValues);
            }
    
            public override void ExecuteResult(ControllerContext context)
            {
                var httpContext = HttpContext.Current;
    
                // ASP.NET MVC 3.0
                if (context.Controller.TempData != null &&
                    context.Controller.TempData.Count() > 0)
                {
                    throw new ApplicationException(
                         "TempData won't work with Server.TransferRequest!");
                }
                // change to false to pass query string parameters 
                // if you have already processed them
                httpContext.Server.TransferRequest(Url, true);
    
                // ASP.NET MVC 2.0
                //httpContext.RewritePath(Url, false);
                //IHttpHandler httpHandler = new MvcHttpHandler();
                //httpHandler.ProcessRequest(HttpContext.Current);
            }
        }
    

    However this method require to run on IIS or a IIS Expres Casinni is not supporting a Server.Transfer method

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

Sidebar

Related Questions

I'm trying to come up with an answer to two questions that didn't seem
I'm trying to come up with the largest possible group of friends that would
Currently trying to come up with a best practice for a ZF site that
I'm trying to come up with a PostgreSQL schema for host data that's currently
I have been trying to come up with a better localization approach than LocBaml
I'm trying to create a chaining function for working with strings that are returned
Hi I was trying to figure out how to create a border that fades
I've come across a scenario that I'm not too sure how to approach. We're
im trying to come up with a design for a wrapper for use when
I'm trying to come up with a solution to programmatically enable/disable the network card

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.