The presentation layer is implemented by the Ninesky.web Project, which is responsible for displaying the content of the site, including the Member and Control two regions.
member Area to achieve the management of website content,control area to achieve site system Management . The structure and function diagram are as follows:
First, member area
1. Add Member area
Ninesky.web "Right-click" Add -area.
In the Add Area dialog box that pops up, enter the area name:Member, complete the zone add .
2. Add Home Controller
ninesky.web->areas->member->controllers "Right-click" Add -area.
Select MVC 5 Controller-NULL and click the Add button.
In the Add Controller dialog box, enter "HomeController" to click the Add button. The generated code is as follows:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSYSTEM.WEB.MVC;namespaceninesky.web.areas.member.controllers{/// <summary> ///Master Controller/// </summary> Public classHomecontroller:controller {/// <summary> ///Main Page Face/// </summary> /// <returns></returns> PublicActionResult Index () {returnView (); } }}
3. Add a view for the Index method
On the Index method, right-click Add View .
In the Add View dialog box, view name: Index, Template:Empty, option tick use layout page, Click the Add button to complete the view Add.
Press F5, 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
OpenMemberAreaRegistration.cs ,Member, ninesky.web,areas
Add the namespaces parameter for 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, you can see the normal page.
Second,control area
The Control area is the same as the member region.
1. Add Control Area
Ninesky.web "Right-click" Add-area. in the Add Area dialog box that pops up, enter the zone name :Controlto complete the zone additions .
2. Add Home Controller
ninesky.web->areas->Control->controllers "right-click" Add -zone.
Select MVC 5 Controller-NULL and click the Add button.
In the Add Controller dialog box, enter "HomeController" to click the Add button.
3. Add a view for the index method
On the home controller 's Index method, right-click Add View .
In the Add View dialog box, view name: Index, Template:Empty, option tick use layout page, Click the Add button to complete the view Add.
4. Modify Member Zone routing
Open Ninesky.web,areas,Control,ControlAreaRegistration.cs
Add the namespaces parameter for 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 source file.
MVC5 Web site development of the five presentation layer architecture