Area, qscrollarea visible Area

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.