Objective
asp.net mvc has been around for some time as Microsoft's official MVC solution. It can be said that since the automatic launch, has been widely concerned. After a long preview, a few days ago finally launched its beta version. And in official documents, Microsoft has stated that the final official version will not change much compared with the beta version. So, for. NET platform developers, it's time to learn asp.net mvc.
This series of articles, as an introductory tutorial on ASP.net MVC, will not be a lengthy introduction to the concepts and theories. Instead, we learn asp.net MVC through case practice. In this series I will step through a "Bulletin publishing system". My writing strategy is to do it first, to explain it when you need to explain concepts and theories, rather than explain the concepts and theories before you do something.
In addition, I have a few points to explain:
1. In order to focus your attention on ASP.net mvc, the demo's business process will use a mock approach. That does not really go to the database, but virtual some data.
2. This demo will not consider any art problems.
Now, let's start asp.net mvc together. In this article, we will finish all the preparation work.
Configuring the Environment
If you have not installed asp.net mvc, please download the installation here.
After downloading, follow the prompts to install it.
New Project
After installing ASP.net mvc, create a new project in VS, see a "asp.net mvc Web Application" option, select it, create a new project, and name it "Mvcdemo."
After you've built the project, you can see that many folders have been created by default, and here's a quick look at how each folder works.
content--to store the application needs of some resource files, such as pictures, CSS and so on.
controllers--storage controller class.
models--stores business model components.
scripts--store JavaScript script files.
views--store views.
Now do not understand some of the concepts do not matter, subsequent articles will be explained slowly.
Preparatory work
After the project has been created, the preparation we have to do is to build mock business models so that we can use these "deceptive" business models directly for business processing, and focus all of our attention on asp.net mvc learning.
First, create three folders under models, called entities, interfaces, and Mockmodels, which are used to store entity classes, interfaces, and mock business models, respectively.
There are two classes under entities: CategoryInfo and Announceinfo, respectively, the entity classes for bulletin categories and announcements. The specific code is as follows:
CategoryInfo.cs:
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5
6namespace MVCDemo.Models.Entities
7{
8 /**//// <summary>
9 /// 分类实体类
10 /// </summary>
11 public class CategoryInfo
12 {
13 public int ID { get; set; }
14 public string Name { get; set; }
15 }
16}