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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:22:16+00:00 2026-06-08T07:22:16+00:00

I have a need for some dynamic routing. So my routes would look like

  • 0

I have a need for some dynamic routing. So my routes would look like this:

{UserName}
{UserName}/Edit/{id}
{UserName}/Delete/{id}

Where the users would be routed to the user controller. But I still want to maintain routes to controls like:

{Controller}/Edit/{id}
{Controller}/Delete/{id}

So basically I want it to direct to the physical controller say called OrdersController for edit delete but if someone navigates to /jdoe/ it sends it to the user controller.

How do I do this in my routes?

  • 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-08T07:22:18+00:00Added an answer on June 8, 2026 at 7:22 am

    You need to create multiple routes, and keep them in the appropriate order

    // one route for Users
    routes.MapRoute("Users",
         "{username}/{action}/{id}",
         new { controller = "Users", action = "Index", username = string.Empty, id = UrlParameter.Optional },
         new { id = @"\d+" }
    );
    // one route for everything else
    routes.MapRoute("Default",
         "{controller}/{action}/{id}",
         new { controller = "Home", action = "Index", id = UrlParameter.Optional},
         new { id = @"\d+" }
    );
    

    It’s not “really” as easy as above, but that’s the jist of it. You would need too add a RouteConstraint to validate usernames.

    Lastly, if you’re using the username parameter, then why do you need the id? Just a thought.


    Aside:
    If you look at the user section here on StackOverflow, you’ll see the routing look more like this.

    • users/{id}/{username}
    • users/{id}/edit
    • users/{id}/delete

    I would personally say that this is a lot less work to achieve… but hey, that’s just me.

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

Sidebar

Related Questions

I would still need some help with my dynamic selectlist. I have the sript:
Problem I have some pages that need dynamic data from website to generate output
I implemented Dynamic DataSource Routing for Spring+Hibernate according to this article . I have
I need to have some dynamic text on thumb in SeekBar is it possible?
I have an application in which I need to show some dynamic bar graphs
I need some help with defining a dynamic method. Basically, I have many classes
I need some help with a CSS layout. It is set up like this:
I need some help with some dynamic jQuery - if thats what it would
I need some sort of dynamic array in C++ where each element have their
I have an c# Class Library where I need some dynamic template based text.

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.