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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:06:29+00:00 2026-05-27T22:06:29+00:00

I have a data model for a directory type structure that looks something like

  • 0

I have a data model for a directory type structure that looks something like this:

Folder:
   String Name
   Folder Parent
   List<File> Files

File
   Folder Parent
   Content

Files and folders at the root level would have a null parent. For navigating folders I would like to be able to have urls that look something like:

http://mysite.com/directoryA/directoryB/directoryC/

I realize this has a bit of redundancy, but I feel it has better readability, and makes a good deal of sense in this case. Using default routes, that same folder would look like:

http://mysite.com/Folder/directorycID

which does not read nearly as nice. Are there any existing patterns that can do this type of routing? The problem with using names instead of ID’s is that I would have to trace the entire structure from the root, since names are only guaranteed unique within a parent directory. Is there a route type that can just give the controller a list of directories, and I can sort out the relationships in the controller? It would be a bit more work, but I could deal with that.

  • 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-27T22:06:30+00:00Added an answer on May 27, 2026 at 10:06 pm

    Unfortunately, ASP.NET routing in the context of ASP.NET MVC doesn’t work too well with an arbitrary number of url segments like folder1/folder2/folderN. You could do a catchall route:

    ...MapRoute(null, "{*folders}", 
        new { controller = "DirectoryStructure", action = "Parse"}
    );
    

    DirectoryStructureController.Parse action method would then look like this:

    public ActionResult Parse(string folders) {...}
    

    You could split the string to determine which content to return, whether to redirect to another action, or return HttpNotFound.

    Update

    The problem with the approach above is that all of your URL’s would be routed to the DirectoryStructureController. You could eliminate this by using a prefix like filesystem:

    ...MapRoute(null, "file-system/{*folders}", 
        new { controller = "DirectoryStructure", action = "Parse"}
    );
    

    Then, requests would not be routed to this controller unless they were prefixed with /file-system like so:

    http://mysite.com/dirA/dirB/dirN/ <-- will not be routed
    http://mysite.com/file-system/dirA/dirB/dirN/ <-- will be routed
    

    Update2

    I also just realized this route would only work for resolving incoming URL’s. You wouldn’t be able to use it to generate an outgoing URL.

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

Sidebar

Related Questions

I have a data model that includes common columns like addedBy, editedby (user), addedDate,
I have a relationship in a Core Data model that feels like it wants
I have an Entity Data Model that I have created, and its pulling in
My Techie Bretheren (and Sisteren, of course!), I have a LinqToSql data model that
I have an iPhone app that has a sqlLite Core Data model that is
I've written a rails app that follows the regular directory structure (model code in
In a webapp, i have a data-model (let's call it Item). The data of
I have a simple data model of two tables, email and recipients, email can
I have made a data model, and now I've made a 2nd version. All
I have data coming into my Model, how do I setup to insert 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.