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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:40:13+00:00 2026-05-14T07:40:13+00:00

When running the MVC 2 Areas example that has a Blog Area and Blog

  • 0

When running the MVC 2 Areas example that has a Blog Area and Blog Controller the URL looks like this:

http://localhost:50526/Blog/Blog/ShowRecent in the format:

RootUrl / AreaName / ControllerName / ActionName

Having just discovered MVC Areas, it seem like a great way to organise code, ie create an Area for each section, which in my case each section has its own controller. This means that each AreaName = ControllerName. The effect of this is the double AreaName/ControllerName path in the Url eg /Blog/Blog/ above

Not having a complete clear understanding of routing, how could I setup routing to not show the AreaName?

EDIT:

I am trying to reduce the amount of work with routes as these appear to effect each other (ie require specific ordering) and may cause major headaches 🙂 In converting an existing webform app to MVC, I have converted a couple of core sections, These have one Controller each and a fair amount of View/Actions and although most of the Data Access is code is in assemblies the number of Model/ViewData classes is growing… I am currently creating sub-folders in the Root Models/Views folders for these sections (or Areas) and was hoping that creating Areas would work the same way except having the code organised (with the use of a basic route that covers the Area)
Any comment on this?

  • 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-14T07:40:14+00:00Added an answer on May 14, 2026 at 7:40 am

    Inside each area’s folder you’ll see a *AreaName*AreaRegistration.cs file. This is where the area routeing rules are stored. By default, as they are generated, they will contain the area name ahead of everything else.. The problem is: if you remove the area name “folder” from the route, the route will catch all “standard” {controller}/{action}/{id} requests. Which is obviously not what you want..

    To overcome this you can add the regex filters on the routes, based on the controller names present in that route. The drawback? You won’t be able to have two controllers with the same name within the app (at least not using the standard route.. You can always think of a different route to access them 🙂 )

    In the end.. Having this structure:

    /Areas
    /Areas/Blog/Controllers/BlogController.cs
    /Areas/Blog/Controllers/FeedController.cs
    /Areas/User/Controllers/UserController.cs
    /Controllers/PageController.cs

    What you should have is sth like this:
    In BlogAreaRegistration.cs:

    context.MapRoute(
        "Blog_default",
        "{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional },
        new { controller = "(Blog|Feed)" }
    );
    

    In UserAreaRegistration.cs:

    context.MapRoute(
        "User_default",
        "{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional },
        new { controller = "(User)" }
    );
    

    In Global.asax.cs:

    public static void RegisterRoutes(RouteCollection routes)
    {
        context.MapRoute(
        "Default",
        "{controller}/{action}/{id}",
        new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
    
        RegisterRoutes(RouteTable.Routes);
    }
    

    Note that in global.asax area registrations come first! 🙂

    UPD:
    Based on your question update:
    There us one major thing that you’ll have to take into consideration if you will use areas: If you have a inter-area link, you’ll also have to provide the area name in the link. E.g.

    <%: Html.ActionLink("Link text", "Action", "Controller", new { area = "Blog", id = 4, title = "page-title" }); %>
    

    You get the idea.

    Regarding the multiple models/views, at the moment I’m following a structure like this

    /Code/ // helper, extension classes that aren’t moved to libraries
    /Models/Data/ // The EF classes + validation classes are here
    /Models/ViewModels/{controller}/ // view models stored per controller

    So far it works fine, and I managed to keep the solution relatively organised. As I stated, the only area that I created so far is the Admin area because it’s that much different from the rest of the website 🙂

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

Sidebar

Related Questions

I'm developing a web app with asp.net mvc 2. This app, has a controller
running asp.net mvc website that has code that connects to oracle. Works fine on
I have an asp.net mvc app running on a local iis website that is
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
Where can I find some good pointers on best practices for running ASP.NET MVC
Our workstations are running 64-bit Vista, and the production servers for our ASP.NET MVC
I have a new ASP.NET MVC project (my first), and I had been running
running git instaweb in my repository opens a page that says 403 Forbidden -
Running into a problem where on certain servers we get an error that the
Running FxCop on my code, I get this warning: Microsoft.Maintainability : 'FooBar.ctor is coupled

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.