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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:10:50+00:00 2026-05-31T04:10:50+00:00

I am wondering how people handle nested/complex routes for an application when using a

  • 0

I am wondering how people handle nested/complex routes for an application when using a data-driven menu structure?

I’ve got two classes for my data driven menus:

 public class List : Entity
{
    public virtual ICollection<ListItem> ListItems { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public ListType ListType { get; set; }

    public string UlTagCssClass { get; set; }
    public string UlTagCssID { get; set; }
}

 public class ListItem : Entity
{
    public virtual List List { get; set; }
    public virtual ListItem ParentItem { get; set; }
    public virtual ICollection<ListItem> ChildItems { get; set; }

    public int SortOrder { get; set; }
    public string Text { get; set; }
    public string Controller { get; set; }
    public string Action { get; set; }
    public string Url { get; set; }
}

I then have a recursive function that spits out any List into a nested ul tags (which is used as a menu). As it stands right now the ListItem can have a URL via straight up full URL, provide a controller and action, or not be a link at all.

However, I am running into a problem in that the URLs don’t match the hierarchy of the menu, which is pretty common practice and most people would expect.

So for example I have a menu hierarchy such as:

  • About
  • Contact
    • Departments
      • Human Resources
      • Sales

So right now my top level item Contact has .Controller = "Contact". It’s child item Departments has .Controller = "Content", .Action = "Departments". It’s link as you would expect goes to http://www.domain.com/Contact/Departments. But my third level item Sales now has .Controller = "Departments, .Action = "Sales". This makes the link http://www.domain.com/Departments/Sales, which doesn’t make sense in the hierarchy of the menu.

What is a good approach to store the proper URL and generate the routes to support that (I can change the ListItem class if necessary)? Also how would one structure their views/controllers in such a scenario? I am not sure how to continue with the increasing depth as I’ve only ever really developed MVC apps where I hard-coded routes or just used the default controller/action route, but now I am trying to make it more data-driven.

  • 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-31T04:10:51+00:00Added an answer on May 31, 2026 at 4:10 am

    Add the following route and add it before your default routes:

    Dynamically map these on application launch by pulling in your menu list and iterating down through the list.
    I would prefer not to dynamically map these unless they change on the fly
    As you need supporting files (views, etc) that you likely don’t create dynamically

     routes.MapRoute("Contact", "Contact/{action}", 
                     new { controller = "Contact"});
     routes.MapRoute("Departments", "Contact/Departments/{action}", 
                     new { controller = "Departments"});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering how how people handle Authorization when using MVVM and/or View Models. If
I was wondering what people thought of using properties as object initializers in C#.
I'm wondering how people are currently resetting their data / cleaning up test remnants
I was wondering - how do people handle importing large numbers of commonly used
Just wondering what people had for ideas on how best to handle events in
I was wondering how people handle dealing with references across multiple users across multiple
I was wondering how people with more experience and more complex projects get along
I was wondering how people handle return statements in a function. I have a
I was wondering how people handle a ListBox control that has no items? e.g.
Just wondering why people like case sensitivity in a programming language? I'm not trying

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.