This article reposted from http://www.asp.net/mvc/tutorials/mvc-music-store,ByMeFlipTranslation.
Recently, the company has had fewer things, so there was a lot of time to "rush". I saw a discussion of MVC in the group, but I have never touched on MVC since I graduated. In the past (including the present), projects were generally written in a three-tier structure, all of which were old-fashioned. I found some information on the Internet, but it is hard to understand. Later I switched to msdn and found that many of the tutorials were good,Lao Zhao Series of tutorials, a little incomprehensible (did not take it seriously, sorry ). For a dish that has never been used to MVC, I don't know about it.CodeIs very difficult, this series of tutorials is good.
Overview:
The MVC music store is an MVC application.ProgramTutorial, which guides learners step by step to develop Web applications using MVC and Visual Studio. We will start from the most basic (create an MVC project), so it doesn't matter if you only have development experience for Web beginners.
We will create a simple music store, which consists of three parts: shopping, checkout, and management.
We can browse by album category:
We can view the specified album and add it to the shopping cart:
You can view the items that have been added to the shopping cart and manage them (such as editing and deleting ):
During the checkout, you will be prompted whether the user is a new user (registered account) or an old customer (directly logged on ):
After creating an account, enter the information on the order and make a payment. For the sake of simplicity, we need to make an amazing promotion: If we select "free" during shopping checkout, everything will be free!
After confirming the order, we will see a simple confirmation interface:
We will create a page that the administrator can manage to facilitate the Administrator to create, edit, and delete items:
1. File-> new project
Create a new ASP. net mvc 3 Project
Start Visual Studio 2010, select "new-> project" from the "file" menu, and enter the "new project" dialog box.
Select Visual C #-> web template group on the left, and then select "ASP. net MVC 3 web application, name the solution as "mvcmusicstore", and then press "OK"
Next, a second-level dialog box is displayed. We will make some specific settings for the MVC project. Select the following options:
Project template-select null
View engine-select razor
Use HTML5 semantic tag-Check
Confirm your settings, as shown in. Then, click OK.
In Solution Explorer on the right, we can see the newly created MVC music store project.
The newly created ASP. net mvc 3 project is not completely empty. By default, IDE (vs2010) creates a basic directory structure.
In the newly created ASP. net mvc project, IDE uses some basic naming conventions to name folder names.
Folder |
Function |
/Content |
Contains images and CSS files |
/Controllers |
Process the content entered by the browser, decide what to do, and return the result |
/Models |
Data and operations on Data |
/Scripts |
JavaScript files |
/Views |
Ui Template |
Even if an empty ASP.. Net MVC applications also contain these folders. By default, these folders are Asp. the. net mvc framework uses the "Conventions due to configuration" method to set some default settings. For example, by default, if you do not explicitly specify which views belong to a project, the program searches for views under the view folder by default. Using this Convention can reduce the amount of code to be written. It is important that other developers can easily understand your project. In the future, we will use this Convention more in the project.
NOTE: If IDE (vs2010) does not have ASP. net mvc 3, download the installation package-Example
Http://www.microsoft.com/downloads/en/details.aspx? Displaylang = en & familyid = d2928bc1-f48c-4e95-a064-2a455a22c8f6, select a language based on your preferences. Note: If you want to install the Chinese language, first install the 20.9m file, and then install the Chinese Language Pack (1.8 m.
Learners can follow this series of tutorials, You can also download the complete source code (official): http://mvcmusicstore.codeplex.com
(Exclusive) My IDE environment, because I am also a beginner, so I also learn based on this series of tutorials. I willArticleAt the end of this article, I want to write some beginner's experience.