In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about the preparation of ASP.NET MVC, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Configure the environment
If you have not already installed asp.net.mvc, please download and install it here.
After downloading, follow the prompts to install it.
New project
After installing asp.net.mvc, create a new project in VS, you can see that there is an option for "asp.net.mvc Web Application", select it, create a new project, and name it "MVCDemo".
After you finish the project, you can see that many folders have been created by default. Here is a brief description of the role of each folder.
Content-- stores some resource files needed by the application, such as pictures, CSS and so on.
Controllers-- stores the controller class.
Models-- holds business model components.
Scripts-- stores JavaScript script files.
Views-- stores views.
It doesn't matter if you don't understand some concepts now, which will be explained in the following articles.
Preparatory work
After the new project, the preparatory work we need to do is to build the Mock business model, so that in the future we will directly use these "deceptive" business models for business processing, and focus all our attention on the study of asp.net.mvc.
First, create three new folders under Models, called Entities, Interfaces, and MockModels, to store entity classes, interfaces and Mock business models, respectively.
There are two classes under Entities: CategoryInfo and AnnounceInfo, which are the announcement category and the entity class of the announcement, respectively. The specific code is as follows:
CategoryInfo.cs:
Using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MVCDemo.Models.Entities {/ classified entity class / public class CategoryInfo {public int ID {get; set;} public string Name {get; set;}}
AnnounceInfo.cs:
Using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MVCDemo.Models.Entities {/ announcement entity class / public class AnnounceInfo {public int ID {get; set;} public string Title {get; set;} public string Content {get; set;} public int Category {get; set;}}
Next, we will define two interfaces, which are the announcement category service and the interface that the announcement service must implement. These two interfaces are placed under Interfaces.
ICategoryService.cs:
Using System; using System.Collections.Generic; using System.Linq; using System.Text; using MVCDemo.Models.Entities; namespace MVCDemo.Models.Interfaces {/ Classification Service component Interface / public interface ICategoryService {/ add category / void Add (CategoryInfo category) / modify the category name / void ChangeName (int id,string name); / delete the category / void Remove (int id) / CategoryInfo GetDetail (int id); / all categories / List GetAll ();}}
IAnnounceService.cs
Using System; using System.Collections.Generic; using System.Linq; using System.Text; using MVCDemo.Models.Entities; namespace MVCDemo.Models.Interfaces {/ announcement Service component Interface / public interface IAnnounceService {/ publish announcement / void Release (AnnounceInfo announce) / / modify announcement information / void Notify (AnnounceInfo announce); / delete announcement / void Remove (int id) / get announcement details / AnnounceInfo GetDetail (int id); / get all announcements under a category / List GetByCategory (CategoryInfo category) }}
Then, we build two Mock business logic service models under MockModels. Note that they each implement their own interfaces.
MockCategoryService.cs:
Using System; using System.Collections.Generic; using System.Linq; using System.Web; using MVCDemo.Models.Interfaces; using MVCDemo.Models.Entities Namespace MVCDemo.Models.MockModels {/ "spoofing" service component, used to simulate classified business services / public class MockCategoryService: ICategoryService {/ add categories / public void Add (CategoryInfo category) {return } / modify the category name / public void ChangeName (int id, string name) {return } / delete the category / public void Remove (int id) {return } / public CategoryInfo GetDetail (int id) {return new CategoryInfo {ID = id, Name = "* Notification" } } / get all categories / public List GetAll () {List categories = new List (); for (int I = 1; I
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.