ASP. NET MVC Areas Zone description

Source: Internet
Author: User

General site is divided into the front desk + members backstage + admin backstage, do webform people will put the member background page in the user, the admin background page in the admin

Member backstage visit:www.xxx.com/user/xxx.aspx

Admin background access:www.xxx.com/admin/xxx.aspx

But a lot of people go to MVC and don't know what to do.

In fact, MVC has already thought for us all, that is areas( region )

The following is an example of a news system:

1. Project right-add-zone

Description: A new folder has been added to the root directory areas, there is a admin,admin inside the MVC 3 folders and a Routing settings class

You can create a new controller and action in the admin, as if it were an MVC project.

2. Create a new controller in the zone admin

In Admin controllers right-click New Controller Newscontroller and then access http://localhost:8080/Admin/News/Create

3. New Zone User

Repeat steps 1th, 2 to create a new zone user, then right-controllers the new controller Newscontroller in user, and then access http://localhost:8080/user/News/Create

4. root directory New Controller

Due to business requirements, the root directory also needs to create a new controller Newscontroller, Access http://localhost:8080/News/Create

Description: Send error, everybody don't worry, this is because the route does not recognize multiple named controllers

5. Modify the routing RouteConfig.cs

Modify the routing RouteConfig.cs (in the root directory App_start folder) so that routing is performed based on the controller's namespace

6.

Access to 3 news/create are normal.

ASP. NET MVC Areas Zone description

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.