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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:26:25+00:00 2026-05-26T06:26:25+00:00

Perhaps I do not understand correctly how MVC Areas work, but this has got

  • 0

Perhaps I do not understand correctly how MVC Areas work, but this has got me a little confused.

  1. Add an Area called “MyArea” using right-click “Add Area” in Visual Studio on the MVC3 project
  2. Create a controller for MyArea: “AnArea” with matching view in the MyArea area.
  3. Add “controller = “AnArea” to context.MapRoute’s defaults parameter in MyAreaAreaRegistration.RegisterArea method.

So at this point if you start the application and navigate to /MyArea/ it should load the AnArea controller with it’s matching view. If you navigate to /MyArea/AnArea, it will show the same result.

But, if you navigate to /AnArea/, the controller is still found and the following error message is displayed:

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/anarea/Index.aspx
~/Views/anarea/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/anarea/Index.cshtml
~/Views/anarea/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml

Is this the correct behaviour? I would have thought an area’s controller could only be accessed via it’s own area and not globally.

  • 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-26T06:26:25+00:00Added an answer on May 26, 2026 at 6:26 am

    Whenever I create an project with areas, I change my Default route as follows:

        routes.MapRoute( 
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // defaults
            null,  // constraints
            new string[] { "MyApplication.Controllers" } // namespaces
        );
    

    The final parameter limits the default route to the controllers in the MyApplication.Controllers namespace. This insures that the Default route is limited to actions outside of any areas.

    UPDATE

    After a deep dive into the code, I discovered where the issue arises, and have a solution. Change your Default route to the following:

    routes.Add(
        "Default", 
        new Route("{controller}/{action}/{id}",
            new RouteValueDictionary(
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            ),
            null,
            new RouteValueDictionary(
                new {
                    Namespaces = new string[] { "MyApplication.Controllers" },
                    UseNamespaceFallback = false 
                }
            ),
            new MvcRouteHandler()
        )
    );
    

    The key is in adding the UseNamespaceFallback token. This will prevent the Default route from looking into any other namespaces.

    This is unexpected behavior, and it was a problem I was unaware of which affects a project I am working on. I will list it as an issue at aspnet.codeplex.com. I would not call this a bug, but the behavior definitely appears to breach the convetions for MVC routing.

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

Sidebar

Related Questions

This question is related to (but perhaps not quite the same as): Does Django
Perhaps I am not asking or searching for this correctly: I want to have
Perhaps this is a naive question. In my understanding, ASP.NET MVC cannot work with
Perhaps not directly programming related, but definitely product / commercially related. And I can't
I can't seem to get it to work. Perhaps I'm not even testing it
I'm not sure what this practice is actually called, so perhaps someone can edit
I understand that the following code can (perhaps not very efficiently) find out a
I have some Haskell code that does work correctly on an infinite list, but
This is from Orchard CMS codegen. I do not understand and how the code
Since my question from yesterday was perhaps not completely clear and I did not

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.