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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:46:38+00:00 2026-05-16T19:46:38+00:00

How and where do I configure my application so that, when it launches, the

  • 0

How and where do I configure my application so that, when it launches, the action (thus the page to be displayed) be, not in the root structure, but rather in a given area of my choice?

Let’s say, Action = “IndexOfArticles“, Controller = “Articles“, Area = “News“. I want this setting to be the default when I launch the application.

I’ve worked on the NewsAreaRegistration class and set up the above configuration. now I suspect that, to make it work, I need to do something with Global.asx.cs as well, but I don’t know what to do.

EDIT

This is what I mean

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

The above code, for instance, will cause the application to start with Index action located in Home controller to execute. That’s not what I want.
Thanks for helping.

  • 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-16T19:46:39+00:00Added an answer on May 16, 2026 at 7:46 pm

    Considering the nature of the questions you’ve been asking, I want to recommend a resource that I think you’ll REALLY love. Steven Sanderson’s book “Pro ASP.NET MVC 2 Framework (second edition)” by apress. Chapter 8 in particular goes into a LOT of detail about routing and areas. The book itself is excellent and thourough; one of the best examples of dev/programming books I’ve ever read. It is available in Kindle form, and if you order from apress directly you can get it in PDF e-book form. It is of course available in paper form too:

    Amazon Link

    or

    Direct from Apress

    The specific thing you might want to understand about areas are that they are based on namespaces. When you create an area, the namespace of that area is how MVC locates them and decides what is “in” and area and what isn’t. Generally this means that routing to areas is done via the URLs that have the area’s name as the first folder in the URL, but this maps to the controller’s namespace, not necessarily the physical folder names (though they should match if you want to preserve your sanity).

    The route in Manaf’s example is working “by accident” more than by intent, which is probably why you aren’t quite getting what it does. There is a quirk with ambiguous controller names in the “root area” (that is, the controller’s folder that isn’t in an area). For a route leads to the root area, but it can’t find a controller there, it will scan all areas looking for a match. In this case it finds a match in your news namespace, and works. But this scanning only works if there is only one controller that matches. So if you were to create another controller in another area with the same name, it will fail with a “multiple types found” kind of exception.

    You have two good ways to make this work more reliably. Either by prioritizing the news area in the routes, or by redirection:

    Redirection:

    Instead of routing root requests to a controller in a specific area, you can redirect the Browser to the URL of the area you want them to start on. So they start at “yoursite.com/” and will be redirected to the “yoursite.com/news/articles” URL. To do this, you create a root level controller and use the default route. So, create HomeController in the root controllers folder (not in an area). On that controller create an action method called Index. And in that Index method, redirect them to the controller you really want them to start on.

    In global.asax, you can rely on a pretty standard default route like this:

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

    In your Index action on the Home controller, just redirect the client to the correct controller in the news area using RedirectToAction and specifying the area:

    return RedirectToAction("IndexOfArticles", "Articles", new { area = "News" });
    

    The second technique is to prioritize the route so it knows which area to use. This doesn’t require any root level controllers. Just add a route entry that looks a little like this:

    routes.MapRoute(
        "Default",
        "{controller}/{acion}/{id}",
        new {controller = "Articles", action = "IndexOfArticles", id = UrlParameters.Optional},
        new[] {"YourApplication.News"}
    );
    

    The drawback to this is that the 4th parameter (namespaces) is going to apply to all requests, so it may cause more to be redirected to your specific news area than you wanted. It might be better to be more specific about the second parameter so this route doesn’t catch other requests… perhaps set the second parameter to an empty string so it only catches a site root request.

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

Sidebar

Related Questions

No related questions found

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.