ASP. NET mvc3 practices-getting started

Source: Internet
Author: User
Tags visual studio 2010

1. Introduction

Mvc3 is the MVC framework under the ASP. NET Framework. With mvc3 released in the same period, there is also the latest ASP. NET engine razor. For detailed documentation on mvc3 and razor, see msdn

Msdn: mvc3 reference on msdn. It is recommended to view it quickly.

Msdn: razor introduction. It is recommended that readers who have not used it learn more.

Starting from this article, this blog will launch a series of ASP. NET mvc3 articles to introduce the ASP. net mvc framework and how to use this framework for efficient web development. Readers of this article need to understand the basic knowledge of ASP. NET, MVC Architecture, and Entity Framework. Okay. Let's get started with ASP. net mvc!

2. Execution of MVC applications under ASP. NET Framework

Phase

Details

Receives the first request to the application

In the global. asax file, the route object is added to the routetable object.

Route execution

The urlroutingmodule uses the first matched route object in the routetable set to create a routedata object, and then creates a requestcontext object using the created object.

Create an MVC request processing program

The mvcroutehandler object will create an mvchandler class instance and pass the requestcontext instance to the handler.

Create a controller

The mvchandler object uses the requestcontext instance to identify the icontrollerfactory object used to create the Controller instance (typically the defaultcontrollerfactory class instance ).

Execution Controller

The mvchandler instance calls the execute method of the controller.

Call operation

For controllers inherited from the controllerbase class, the controlleractioninvoker object associated with the Controller determines the operation method of the controller class to be called, and then calls this method.

Execution result

The operation method will receive user input, prepare appropriate response data, and then execute the result by the returned result type. The following built-in result types can be executed: viewresult (rendering a view and the most commonly used result type), redirecttorouteresult, redirectresult, contentresult, jsonresult, fileresult, and emptyresult.



3. Development Environment

The installation package of Visual Studio 2010 only contains MVC2 and needs to be installed independently. We recommend that you use web installer on http://www.asp.net/mvc/mvc3. if you use an independent Asp.net mvc3 installation package, the installation package may be suspended in some steps.

In terms of databases, to facilitate the use of entity framwork, this article uses SQL Server. You do not need to pay too much attention to the configuration. You only need the default configuration to run the content provided in this Article.

Unlike the tedious development environment of MVC in the J2EE framework, ASP. NET only requires the following tools:

Visual Studio Web Developer express 2010

ASP. net mvc 3 tools

SQL Server 2008 Express

The following link is the Web Developer express + mvc3 web installer provided by the Asp.net site.

Http://www.asp.net/mvc/mvc3

However, we recommend that you use the full version of Visual Studio for qualified readers.


4. auxiliary tool nuget

Nuget is a developer-oriented package manager on the. NET platform. nuget is a good news for developers who once struggled with configuration files such as Struts and hibernate. The use of nuget is similar to the package manager in Linux, but it may be simpler. For a project, nuget can do the following:

1. Search for packages;

2. Download the package to your local computer and add it to the project (including adding references and DLL files );

3. automatically configure the config file of the web project according to the package.

For more information about nuget, see the nuget project on codeplex:

Http://nuget.codeplex.com/

Here, we will demonstrate how to use nuget to add the Ajax Control Toolkit to an empty mvc3 project. This will be a very simple process named ^_^.

Create an mvc3 project and select an empty template, as shown in project layout1:

Figure 1.

Right-click "Reference" in the project, click "manage nuget packages" in the pop-up menu, and enter the name of the package to be searched in the search box, as shown in Figure 2:

Figure 2.

Then click Install, and then there will be no more. nuget will complete all the configurations for you!

TIPS: mvc3 project templates, including empty templates, will install several commonly used packages such as entityframework and jquery. These packages can be managed using nuget.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.