Area, qscrollarea visible Area
1. the area mechanism added by mvc4.0 can help you build a large-scale project and make some of the features with higher independence independent into an MVC sub-website to reduce the coupling between the website and the website, you can also use area cutting to reduce the chance of conflict when multiple people develop the same project at the same time. Two controllers with the same name are not allowed in the MVC project.
For example, if you have a homepage when you are building a website, but you want to have other topics, then Area is useful. You can use the jump link to access the subtopics you want to go.
To access a page outside a region, you can use Html. RouteLink to generate a jump link.
We can split different mvc websites in the same project, and each sub-website will have a complete mvc directory structure during development, just like separating them into different mvc websites.
Region created:
Right-click solution manager and add a region. The region name is the name of your subtopic. After you finish, you will find a folder, this folder is almost the same as your MVC project. If you can create one, you can create several sub-topics (regions) in the Area and add a controller in the Area, next we will jump to the page you want to display.
For example, if you want to access a page outside the region in the Admin region, you can use Html. RouteLink to generate a jump link.
@ Html. routeLink ("displayed content", "route name", new {controller = "controller name", action = "Action name "}) // This is written in the view on the page you want to display, for example, in the Index view.
Route name: "Admin_default" in "sub-project name AreaRegistration. cs" on the sub-page you want to display ".
Public override void RegisterArea (AreaRegistrationContext context)
{
Context. MapRoute (
"Admin_default ",
"Admin/{controller}/{action}/{id }",
New {action = "Index", id = UrlParameter. Optional}
);
}
Note: controllers with the same name are not recommended.