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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:45:10+00:00 2026-05-14T19:45:10+00:00

I have a basic MVC 2 (RC2) site with one base-level controller (Home), and

  • 0

I have a basic MVC 2 (RC2) site with one base-level controller (“Home”), and one area (“Admin”) with one controller (“Abstract”). When i call http://website/Abstract – the Abstract controller in the Admin area gets called even though i haven’t specified the Area in the URL. To make matters worse – it doesn’t seem to know it’s under Admin because it can’t find the associated view and just returns:

The view 'Index' or its master was not found. The following locations were searched:
~/Views/Abstract/Index.aspx
~/Views/Abstract/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx

Am i doing something wrong? Is this a bug? A feature?

  • 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-14T19:45:11+00:00Added an answer on May 14, 2026 at 7:45 pm

    My friend and I were experiencing the same issue with Areas in ASP.NET MVC 2. We found a “hack” that, so far, seems to be working. For the tl;dr version, see the bottom of this answer.

    You’ve probably got something similar to the following in your “Admin” area’s “AdminAreaRegistration.cs” class:

    // Web/Areas/Admin/AdminAreaRegistration.cs
    
    public override void RegisterArea(AreaRegistrationContext context) {
        context.MapRoute(
            "Admin_default",
            "Admin/{controller}/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional }
        );
    }
    

    Thus, it should make sense that when you make a request for “http://website/Abstract“, the “Admin_default” route does not match the request. So, by design, the MVC framework attempts to match the request against any other defined routes. If you used the MVC tooling within Visual Studio to create your web project, you’ll have a “Default” route defined in your “Global.asax” file (at the root of your web project). It should look similar to this:

    // Web/Global.asax.cs
    
    public static void RegisterRoutes(RouteCollection routes) {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
        routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new {controller = "Home", action = "Index", id = UrlParameter.Optional}
        );
    }
    

    The “Default” route succeeds in matching the request for “http://website/Abstract“, with “controller” = “Abstract”, “action” = “Index” (default value), and “id” = UrlParameter.Optional (default value). This is the correct, and intended, behavior… so far.

    Now, the MVC framework will attempt to load the “Abstract” Controller. By design, MVC will search for a class called “AbstractController” that extends “Controller” anywhere within the web project’s file/namespace hierarchy. It is important to note that a Controller’s file location and namespace do not affect MVC’s ability to find it; in other words, just because you’ve placed the “AbstractController” within a folder called “Areas\Admin\Controllers” and changed the namespace to be “Web.Areas.Admin.Controllers” instead of, say, “Web.Controllers”, doesn’t mean that MVC won’t use it.

    When MVC executes the “Index” action in “AbstractController” which, most likely, just returns “View()”, then MVC gets confused because it doesn’t know where to find the “Index” view. Because MVC has matched a non-area route (the “Default” route in Global.asax), it thinks the matching view should be located in non-area view folders. Thus you get the familiar error message:

    The view 'Index' or its master was not found. The following locations were searched:
    ~/Views/Abstract/Index.aspx
    ~/Views/Abstract/Index.ascx
    ~/Views/Shared/Index.aspx
    ~/Views/Shared/Index.ascx
    

    We, just as you, didn’t want requests for “http://website/Abstract” to resolve to “Admin” area’s “AbstractController”; only “http://website/Admin/Abstract” should work. I can’t think of why anyone would want this behavior.

    A simple solution is to delete the “Default” route in Global.asax, but this will break any regular non-area Controllers/Views. This is probably not an option for most people…

    So, we thought we could restrict the set of Controllers that MVC would use for requests matched by the “Default” route in Global.asax:

    // Web/Global.asax.cs
    
    public static void RegisterRoutes(RouteCollection routes) {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
        routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new {controller = "Home", action = "Index", id = UrlParameter.Optional},
            new[] {"Web.Controllers"} // Added this line
        );
    }
    

    Nope. A request for “http://website/Abstract” will still use “AbstractController” within the “Admin” area, even though the “AbstractController”‘s namespace is “Web.Areas.Admin.Controllers” and (clearly) not “Web.Controllers”. This is thoroughly confusing; it seems like this white-list has no dicernable affect on MVC’s Controller resolution.

    – tl;dr answer starts here –

    After some hacking, we figured out how to force MVC to only use Controllers within the white-listed namespace(s).

    // Web/Global.asax.cs
    
    public static void RegisterRoutes(RouteCollection routes) {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
        routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new {controller = "Home", action = "Index", id = UrlParameter.Optional},
            new[] {"Web.Controllers"}
        ).DataTokens["UseNamespaceFallback"] = false; // Added this line
    }
    

    Set the “UseNamespaceFallback” key of the DataTokens dictionary on the “Default” route to false. Now, when we make a request for “http://website/Abstract“, the “Default” route will still be matched (this is valid behavior!) but MVC will not use any Controller that is not within the defined namespace(s); in this case, only Controllers within the “Web.Controllers” namespace are valid. Finally, this is the functionality we were looking for! We can’t figure out why this isn’t the default behavior. Weird, huh?

    Hope this helps.

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

Sidebar

Ask A Question

Stats

  • Questions 439k
  • Answers 439k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I figured out what was wrong. I forgot to unset… May 15, 2026 at 4:57 pm
  • Editorial Team
    Editorial Team added an answer The problem turned out to be one of what locale… May 15, 2026 at 4:57 pm
  • Editorial Team
    Editorial Team added an answer These days, email tends to be a lot more reliable… May 15, 2026 at 4:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.