Preface
Hello everyone, from today on, I will write a summary about AspNet MVC3 and share some basic knowledge with beginners. The author is also willing to share his skills with you, let's exchange ideas and make progress together. You are welcome to give me some comments and suggestions. The author's knowledge and knowledge certainly have their own limitations. I hope I can become a non-Cool technician, instead of simply enjoying the technology, let more people share your achievements.
Section 1: Asp. Net MVC3
Asp. Net MVC has reached the third edition. I believe everyone is familiar with it, and I will not repeat related conceptual things. However, you must understand that Asp. Net MVC is an open-source UI Layer framework of Microsoft and another development mode of AspNet. Let's get started with Asp. Net MVC3. To do this, you must first sharpen your tools! Therefore, we must build our own development environment to provide better support for our next learning and development.
The prerequisites for your machine are:
1) VS2010 (of course you have to use VS2008, so I can't say anything)
2) SqlServer 2000/2005/2008
3) Asp. Net MVC3 installation package (VS2010SP1 is required)
Below are some URL links for you to download and learn:
1) As shown in:
This may take a long time (> = 20 minutes) during the installation process!
2) install the Asp. Net MVC3 installation package
3) Asp. Net MVC3 source code Open Source Address:
As shown in:
Section 2: The first Asp. Net MVC3 Project
1) create a project:
2) Select the default view engine of the project.
Select an Empty template, and then select the Razor view engine (Asp. net MVC3 provides a new view engine) Select HTML5 tag support to tick (I don't know about this one, haha, hope you have done this research to share with me !).
3) The created Project:
Asp. Net MVC3 seems similar to the Project template created in the previous version, and the folder is similar. Of course, we can see that the Jquery package in the folder is updated to 1.5.1. In the subsequent articles, we will introduce each folder. This is not a long time.
4) Add the code and run our first Demo.
First, right-click the Controller folder, select Add menu, and then select Controller, as shown in:
In the dialog box that appears, name the Controller HomeController. Do not remove the Controller. Otherwise, it will not be recognized as the Controller. Click Add. As shown in:
The designer automatically generates the following code for us:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. Mvc;
Namespace MvcApplication1.Controllers
{
Public class HomeController: Controller
{
//
// GET:/Home/public ActionResult Index ()
{
Return View ();
}
}
}
Next, add the view we need on the Action, as shown below:
5) add our own Html tag on the front-end page
@{
ViewBag. Title = "Index ";
}
<H2> Index
<H1> Hello! Its my first Asp. Net MVC Web! </H1>
Note: Red is the part we added.
6) final result:
Section 3: Summary
Although I didn't write much in the first article, it's late at night! We will continue to work overtime tomorrow! Write it here now! Of course, this article does not thoroughly explain the respective functions of folders generated by the entire project, and Asp. some related concepts of Net MVC are just a simple demonstration example. There is no technical content. I hope the following article will introduce it in detail. Let's look forward to the following!