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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:52:10+00:00 2026-06-16T18:52:10+00:00

I just realized MVC 3 and 4 Routing can configure the path to the

  • 0

I just realized MVC 3 and 4 Routing can configure the path to the actions which are a part of an area without naming the area name but they don’t return views. for example see the following code :

namespace APS.EIMS.UI.Areas.Admin
{
    public class TestController : BaseController
    {

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult GetNames()
        {
            var dc = GetDataContext();
            var result = from m in dc.Db<IMS_Reject>()
                         select new { m.Id };
            return Json(result, JsonRequestBehavior.AllowGet);
        }

    }
}

whenever I try the //localhost/Test/Index It can not find the Index view but can route the path to the action in the area (it works fine for //localhost/admin/test/index as I expect). I also get the same result for //localhost/admin/test/getnames and //localhost/test/getnames.
why does it act in this way? how can it find the action without the area name? I need to prevent this in my application which I’m developing, is it possible?(I mean route only when the address is complete and 404 error otherwise)

  • 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-06-16T18:52:11+00:00Added an answer on June 16, 2026 at 6:52 pm

    You will probably have a route like the default one:

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

    So a URL like //localhost/Test/Index will be matched against that default route and as you can see, it will correctly find the controller but not the views. By default the controller factory will look for any Controller class in the application with the requested name, no matter where it is located.

    You can prevent this if you explicitly set the namespaces in the default route and tell MVC not to look for controllers in other namespaces.

    This is done by using the MapRoute overload that takes a string array with the namespaces and explicitly disabling namespace fallback for that route. (Without disabling namespace fallback you would be just prioritizing those namespaces in case multiple controllers with the same name are found).

    This could look like this (I have set a single namespace but you could set as many as you need):

    Route route = routes.MapRoute(
        "Default", 
        "{controller}/{action}/{id}",
        new[] { "APS.EIMS.UI.WhateverInNoArea" }
    );
    route.DataTokens["UseNamespaceFallback"] = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to debug a problem with routing and I've just realized that MVC
I just realized that this piece of code works well in Firefox but not
I just realized something crazy, which I assumed to be completely impossible : when
Just a quick question, but I've been working on a small MVC framework and
I just realized that the MySQLWorkBench destroys the target (makes a replacement) when performing
I just realized that I need to synchronize a significant amount of data collection
I just realized a function may be defined inside another function in C: void
I just realized that the method Element.getElementsByTagName(someTagName) returns a nodelist of all elements in
I just realized that i may not be following best practices in regards to
I just realized that when i start a task from within a task and

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.