In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is to share with you about how to achieve the display layer architecture in the development of the ASP.NET MVC5 website. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
The presentation layer is implemented by the Ninesky.Web project, which is responsible for displaying the content of the website. The project includes two areas: Member and Control.
The Member area realizes the website content management, and the Control area realizes the website system management. The structure and function diagram are as follows:
I. Member region
1. Add Member regions
Ninesky.Web [right]-> add-> region.
Enter the region name: Member in the add region dialog box that pops up to complete the region addition.
2. Add Home controller
Ninesky.Web- > Areas- > Member- > Controllers [right]-> add-> area.
Select the MVC 5 controller-null and click the add button.
Enter "HomeController" in the add Controller dialog box and 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 {/ main controller / public class HomeController: Controller {/ main page / public ActionResult Index () {return View ();}
3. Add a view to the Index method
Right-click on the Index method-> add a view.
In the add View dialog box, view name: Index, template: Empty, check the use layout page, click the add button to complete the view addition.
Press F5 to run the project and view http://localhost:52810/Home/Index in the browser. Well, there was a mistake, which means Home found two matching controllers.
4. Modify Member area routing
Open Ninesky.Web- > Areas- > Member- > MemberAreaRegistration.cs
Add the namespaces parameter to the MapRoute. The added code is in the red box in the figure.
5. Modify the default route
Open Ninesky.Web- > App_Start- > RouteConfig.cs
Add a parameter with "namespaces" to the MapRoute. The added code is in the red box in the figure.
Press F5 to run again and you can see the normal page.
II. Control region
The practice of Control regions is the same as that of Member regions.
1. Add Control regions
Ninesky.Web [right]-> add-> region. Enter the region name: Control in the add region dialog box that pops up to complete the region addition.
2. Add Home controller
Ninesky.Web- > Areas- > Control- > Controllers [right]-> add-> area.
Select the MVC 5 controller-null and click the add button.
Enter "HomeController" in the add Controller dialog box and click the add button.
3. Add a view to the Index method
Right click on the Index method of the Home controller-> add a view.
In the add View dialog box, view name: Index, template: Empty, check the use layout page, click the add button to complete the view addition.
4. Modify Member area routing
Open Ninesky.Web- > Areas- > Control- > ControlAreaRegistration.cs
Add the namespaces parameter to the MapRoute. The added code is in the red box in the figure.
The above is how to achieve the presentation layer architecture in the development of ASP.NET MVC5 website, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.