asp.net MVC5 web site development of the display Layer Architecture (V) _ Practical skills

Source: Internet
Author: User

The presentation layer is implemented by the Ninesky.web project, which is responsible for displaying the content of the site, including member and control two areas.

The member area realizes the management of the website content, control area realizes the website system management. Structure, function diagram is as follows:

One, member area

1. Add Member Area

Ninesky.web the "right"-> add the-> area.

In the Pop-up Add Area dialog box, enter the name of the zone: Member, complete the zone Add.

2. Add Home Controller

Ninesky.web->areas->member->controllers the "right"-> add the-> area.

Select MVC 5 Controller-NULL, click Add button.

Enter "HomeController" in the Add Controller dialog box to click the Add button. 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>
  ///host 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-> on the Index method to add a view.

In the Add View dialog box, view name: Index, Template: Empty, Options check Use layout page, click Add button, complete view Add.

Press F5 to run the project and view the Http://localhost:52810/Home/Indexin the browser. Well, something went wrong, meaning home found two matching controllers.

4. Modify Member Zone routing

Open Ninesky.web->areas->member->memberarearegistration.cs

Add namespaces parameters to the Maproute. The code that is added in the red box in the figure.

5, modify the default route

Open Ninesky.web->app_start->routeconfig.cs

Add a parameter with "namespaces" for Maproute. The code that is added in the red box in the figure.

Press F5 again to run and you can see the normal page.

Ii. Control Area

The control area is in the same way as the member area.

1. Add Control Area

Ninesky.web the "right"-> add the-> area. In the Pop-up Add Area dialog box, enter the name of the zone: control, complete the zone Add.

2. Add Home Controller

Ninesky.web->areas->control->controllers the "right"-> add the-> area.

Select MVC 5 Controller-NULL, click Add button.

Enter "HomeController" in the Add Controller dialog box to click the Add button.

3. Add a view for the index method

Right-click on the home controller's Index method to add a view->.

In the Add View dialog box, view name: Index, Template: Empty, Options check Use layout page, click Add button, complete view Add.

4. Modify Member Zone routing

Open Ninesky.web->areas->control->controlarearegistration.cs

Add namespaces parameters to the Maproute. The code that is added in the red box in the figure.

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

Code See: Https://ninesky.codeplex.com/SourceControl/latest

Code Download: https://ninesky.codeplex.com Click Source code click Download to download the original file.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.