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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:35:06+00:00 2026-05-29T21:35:06+00:00

If we have more areas in one project, where should routing values should be

  • 0

If we have more areas in one project, where should routing values should be stored.
What should go to Global.asax and what in class in AreaAreaRegistration.cs
I don’t use asp mvc often (it’s still hobby) but routing makes me problems all the time 🙁
I must give one example that confuse me:
I have two areas and link in one area (CityPage) that should open page in another area.
So in my global.asax I have:

routes.MapRoute(
                "CityPage_home",
                "{country}/{city}",
                new { controller = "Home", action = "Index", country = UrlParameter.Optional, city = UrlParameter.Optional }
            );

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

And this works. But if I move “*CityPage_home*” from global.asax to CityPageAreaRegistration.cs then when I click on link that should open page in another area my application crash because code enters first in CityPage/Home/Index method.
I don’t understand why this routing work in first case and not in another. Any idea?

  • 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-29T21:35:08+00:00Added an answer on May 29, 2026 at 9:35 pm

    Within in each area a file will be generated for you. For example.

    AdminArea would contain a file named AdminAreaRegistration
    With a method like this inside:

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

    I like to modify this by adding a default controller.

    Action Links

    Traditionally we use the following to create a link:

    @Html.ActionLink("MyLink","Index","Home",)

    To create a link to the admin area we use this:

    @Html.ActionLink("Admin Area","Index", new { area = "Admin", controller = "Home" })

    Now if you’re inside the admin and want to place a link to the home page you need to do this:

    @Html.ActionLink("Home","Index", new { area="", controller = "Home })

    And finally, if you need to create custom routes you can put the area routes in the new file that is created within each area, and continue to put your non area specific routes in the normal Global.asax.

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

Sidebar

Related Questions

Where I have more than one table in my database for use with (similar,
I have a few areas in my ASP MVC project. One area has near
I have more than one Event Listener that calls a specific function, and I
How can one have more than a Wizard control on the same page without
I would like to have more than one button. I tried to copy code
We have in one of our applications a single eclipse project that contains all
I have a project with various parts.... One of which is the calculate the
Within a single project solution introducing Areas when you have a lot of controllers
I have implemented endless scrolling to my website user account area and before more
I have more or less been able to understand and implement all these concepts

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.