Presentation layer architecture of ASP. NET MVC5 website development (5), mvc5 website development

Source: Internet
Author: User

Presentation layer architecture of ASP. NET MVC5 website development (5), mvc5 website development

The display layer is implemented by Ninesky. Web projects and is responsible for displaying website content. The project consists of two areas: Member and Control.

The Member area manages website content, and the Control area manages website systems. The structure and function diagram are as follows:

1. Member Region

1. Add a Member Region

Ninesky. Web [Right-click]-> Add-> area.

In the add region dialog box that appears, enter the region name Member to add the region.

2. Add the Home Controller

Ninesky. Web-> Areas-> Member-> Controllers [Right-click]-> Add-> area.

Select the MVC 5 controller-null and click Add.

In the "add controller" dialog box, enter "HomeController" and click "add. The generated code is as follows:

Using System; using System. collections. generic; using System. linq; using System. web; using System. web. mvc; namespace Ninesky. web. areas. member. controllers {// <summary> /// master controller /// </summary> public class HomeController: controller {// <summary> /// homepage /// </summary> /// <returns> </returns> public ActionResult Index () {return View ();}}}

3. Add a view for the Index method

Right-click the Index method and choose add view.

In the add view dialog box, view name: Index, template: Empty, select the use layout page, and click Add to add a view.

Press F5 to run the project. Check http: // localhost: 52810/Home/Index in the browser. Well, an error occurs, which means that Home finds two matched controllers.

4. Modify the Member region route

Open Ninesky. Web-> Areas-> Member-> MemberAreaRegistration. cs

Add the namespaces parameter to MapRoute. The red box in the figure shows the added code.

5. Modify the default route

Open Ninesky. Web-> App_Start-> RouteConfig. cs

Add parameters with "namespaces" to MapRoute. The red box in the figure shows the added code.

Press F5 again to view the normal page.

Ii. Control Area

The method of the Control area is the same as that of the Member area.

1. Add the Control area

Ninesky. Web [Right-click]-> Add-> area. In the add region dialog box that appears, enter the region name "Control" to add the region.

2. Add the Home Controller

Ninesky. Web-> Areas-> Control-> Controllers [Right-click]-> Add-> area.

Select the MVC 5 controller-null and click Add.

In the "add controller" dialog box, enter "HomeController" and click "add.

3. Add a view for the Index method

Right-click the Index method of the Home controller and choose add view.

In the add view dialog box, view name: Index, template: Empty, select the use layout page, and click Add to add a view.

4. Modify the Member region route

Open Ninesky. Web-> Areas-> Control-> ControlAreaRegistration. cs

Add the namespaces parameter to MapRoute. The red box in the figure shows the added code.

========================================================

See: https://ninesky.codeplex.com/SourceControl/latest for code

CODE Download: https://ninesky.codeplex.com click source code click Download to Download the SOURCE file.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.