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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:11:15+00:00 2026-05-30T09:11:15+00:00

I’m working on converting a website with a 4-level directory structure to MVC3 in

  • 0

I’m working on converting a website with a 4-level directory structure to MVC3 in Visual Studio 2010. The examples that I’ve found have routes with {controller}/{action}/{id}.

Thinking about directory structure levels as sections, what I need to do is handle a structure that looks like this:
mysite.com/{section1}/{section2}/{section3}/{section4}

An index file will be at each section, operating as in introduction to the section and a directory. I don’t anticipate any web pages beyond the section-4 level at this time.

My preference would be to use an XML sitemap, and to write some block of code to handle the various page directory structures from that sitemap. I’ve done this successfully with WebForms, but really want to do this with MVC3. The big piece I’m missing is a good working example of doing this.

Right now I can’t even get this to route to Section2. This is in my Global.asax.

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

        routes.MapRoute("",
            "Section1/{controller}/{action}/{id}",
            new { controller = "Section1", action = "Index", id = UrlParameter.Optional }
        );
    }

This is in my Section1 controller.

public class Section1Controller : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult Section2(string id)
    {
        return View("Section2/" + id);
    }
}

I can successfully navigate to Section1 (i.e. http://localhost:123/section1/). But when I enter Section2 (http://localhost:123/section1/section2), this error appears:

The view ‘Section2/’ or its master was not found or no view engine
supports the searched locations. The following locations were
searched: ~/Views/section1/Section2/.aspx
~/Views/section1/Section2/.ascx ~/Views/Shared/Section2/.aspx
~/Views/Shared/Section2/.ascx ~/Views/section1/Section2/.cshtml
~/Views/section1/Section2/.vbhtml ~/Views/Shared/Section2/.cshtml
~/Views/Shared/Section2/.vbhtml

I hope this all makes sense. If there is a better way to approach this, please let me know.

My immediate problem is getting this to navigate out to the index page for each of the sections (1, 2, 3, and 4), with a controller at the section 1 level. If that’s not possible, what is an efficient way to approach this? Either way, I’ll probably need to see a code example.

Second to that, is there a decent way to utilize a sitemap on an MVC3 site? If so, what approach would I use?

Thanks for your help.

  • 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-30T09:11:17+00:00Added an answer on May 30, 2026 at 9:11 am

    The problem with your route is that it comes after the default route. MVC will stop at the first route that matches, which is always going to be the default. You need to move it above the default route in the collection by declaring it first.

    You can solve your problem entirely with routing if the sections are fixed. That’s pretty easy to do.

    The reason your controller based solution didn’t work is because you were trying to pass the id as part of the View name. That’s not how it works. You would do something like this:

    public ActionResult Section2(string id) 
    { 
        return View("Section2", new { id=id }); 
    } 
    

    You can also create Areas, which will create subsections with complete MVC sites within them. Areas are a great feature, but may not be exactly what you want in all cases.

    There’s also Portable Areas, which allows you to seperate areas into their own assemblies and thus their own projects.

    You can also parse your own URL by using what’s known as a “slug” to parse any content that comes after the controller name.

    Regarding Sitemap, you might give this a try

    https://github.com/maartenba/MvcSiteMapProvider

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.