Http://blog.sina.com.cn/s/blog_6ad539a90100qc9t.html
1.1 ASP. NET mvc3 bookstore Overview
ASP. net mvc3 bookstore is a virtual website used only as an example (not a running website). It introduces how to use ASP step by step through the establishment of this website. net MVC and Visual Studio for Web websites and web applicationsProgramDevelopment. We start with the most basic knowledge, so beginners with zero experience can understand the content in this tutorial.
The website we are going to build is the simplest web bookstore with three main components: Book Selection, book settlement, and order management. You can select a book based on the type of the book. You can view the information of a single book and store the book in the shopping cart to view the books in the shopping cart, and delete the books you do not want to continue purchasing from the shopping cart. users who have registered and logged on can go to the settlement page to settle the books. You can enter the Receiving address, contact number, and other receiving information of an individual user. In addition, we also provide the back-end management page on this website. The administrator can delete, query, and modify the book information on the website. This tutorial starts from creating a new ASP. NET MVC2 project using vsual web 20172010, and then gradually adds new functions until a complete application is created. We will involve database access, form submission, data verification, layout using master pages, page update and Verification Using ajax, user logon, and other aspects.
You can use Visual Studio 2010 or visual web developer 2010 express to create this website. The database used in this website is SQL Server Express.
1.2 Create a project
First, click the "new project" sub-menu under the "file" menu in Visual Web Developer, as shown in Figure 1-1.
Figure1-1Click "new project" sub-menu
Click the "new project" sub-menu to bring up the "new project" dialog box. In this dialog box, click the "Web" Template under the C # option, and then select "ASP. net mvc3 web application ", name our application mvcbookstore, as shown in 1-2, and click OK.
Figure1-2NewASP. net mvc 3 WebApplications
Click OK. The select project template dialog box is displayed. In this dialog box, we can set some specific MVC settings for our project. Select an empty template, select the "Razor" option in the view engine, as shown in figure 1-3, and click "OK.
Figure1-3Select an empty template andRazorView Engine
After you click OK, your project is automatically created, as shown in figure 1-4.
Figure1-4 ASP. NET mvc3 WebThe project is automatically created.
Next, let's check which folders are added to our application in Solution Explorer on the right, as shown in 1-5.
Figure1-5 ASP. NET mvc3 WebBasic folder in the project
The blank mvc3 template does not mean that nothing is done. In fact, it adds a basic folder structure. The specific descriptions are shown in Table 1-1.
Table1-1 ASP. NET mvc3 WebDescription of basic folders in the project
Folder |
Description |
Controllers |
The Controller Used to respond to input requests in the browser. The Controller determines what to do next and returns the response to the user. |
Views |
Store the view template file. The view displays the user interface for interaction with users. |
Models |
Stores models used to map data. |
Content |
Stores website images, CSS, and other static content. |
Scripts |
Store JavaScript files. |
App_data |
Store database files. |
Even if you selectASP. NET mvc3When the template is selected, a blank template is selected, and the above folders will be automatically created. This is becauseASP. net mvc FrameworkBy default, a "setting Convention" is used, and some assumptions are made based on the folder naming convention. For example, by default, the ControllerViewsFind the view template file in the file folder, unless youCodeExplicitly specify the storage location of the view template file. Keeping this default "setting Convention" can reduce the amount of code you need to write, and improve the readability (or comprehensibility) of your entire application when it is read by other developers ). Later, we will introduce these default conventions with the development of the entire application.