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.