MVC5 website development-5 presentation layer architecture, mvc5 website development

Source: Internet
Author: User

MVC5 website development-5 presentation layer architecture, mvc5 website development

Display layerNinesky. WebProject implementation: displays the website content. The project includesMemberAndControlTwo regions.

Member RegionTo manage website content,Control AreaImplement Website System Management. The structure and function diagram are 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.IndexMethod to add a view

 

InIndexRight-click the method and choose>Add View.

 

InAdd ViewIn the dialog box, view Name:Index, Template:Empty, SelectUse the layout page,ClickAddButton to add the view.

 

PressF5Run the project and check it in the browser.Http: // localhost: 52810/Home/Index. Well, an error occurred,MeaningHomeFind two matched controllers.

 

4. ModifyMemberRegion Routing

OpenNinesky. Web->Areas->Member->MemberAreaRegistration. cs

IsMapRouteAddNamespacesParameters. The red box in the figure shows the added code.

5. ModifyDefaultRouting

OpenNinesky. Web->App_Start->RouteConfig. Cs

IsMapRouteAddNamespacesParameters. The red box in the figure shows the added code.

PressF5Run, you can see the normal page.

II,Control Area

ControlRegional Practices andThe Member region is the same.

1. Add the Control area

Ninesky. Web [Right-click]-> Add-> area.InAdd region dialog boxEnter region name:Control,Add Region.

2. Add the Home Controller

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

SelectMVC 5 controller-null,ClickAddButton.

In theAdd Controller"Dialog box, enter"HomeController"ClickAddButton.

3. Add a view for the Index method

InHome ControllerOfIndexRight-click the method and choose>Add View.

InAdd ViewIn the dialog box, view Name:Index, Template:Empty, SelectUse the layout page,ClickAddButton to add the view.

4. Modify the Member region route

OpenNinesky. Web->Areas->Control->ControlAreaRegistration. cs

IsMapRouteAddNamespacesParameters. The red box in the figure shows the added code.

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

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

Code download: https://ninesky.codeplex.comClickSOURCE CODEClickDownloadDownload the source file.

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.