Asp.net Mvc is a framework for compiling Asp. netWeb applications in the Mvc mode officially provided by Microsoft. It comes from Castle's MonoRail. It has already gone through several versions
Http://www.asp.net/mvc/
At the same time, asp.net Mvc also provides a community preview: http://www.codeplex.com/aspnet
The above two websites can be used to obtain the AspNetMVc Installation File.
The download will get an installation file for the AspNetMVCPreviewX-setup.msi
Double-click to install
Open Visual Studio 2008 ()
Click File> New> Project in the menu.
Select C #> Web in the project type (select. net Framework 3.5 in the Framework above ).
Select Asp. Net Mvc Web Application to create a project.
If the project template does not appear, run X: \ Program Files \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ devenv.exe/setup in the command line.
X indicates the drive letter for Vs installation.
In official versionsA "Create Test Project" window appears when you Create a Project to check whether a Test Project is created. Generally, the Project is created by default.
After confirmation, two new projects will appear.
Asp.net MVC project MvcApplication1
Asp.net MVC test project MvcApplication1Tests
MvcApplication1
By default, a "My Sample MVC Application" website is displayed.
The following describes the structure of the program.
Maybe the concept you mentioned here is a bit vague. Let's take a look at how this simple program is written. Let's open Controller/HomeController. cs
The Code is as follows:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. Mvc;
// Follow the order of 1.2.3.4 numbers.
Namespace MvcApplication2.Controllers
{
/// <Summary>
/// 1. HomeController corresponds to the Home folder in Views
/// </Summary>
Public class HomeController: Controller
{
/// <Summary>
/// 2. This is called Action. The Action name (name) is Index.
/// By default, this parameter corresponds to
/// The Aspx file with the same name (Views/Home/Index. aspx) in the corresponding folder (Views/Home)
/// </Summary>
Public ActionResult Index (){
// 4. This is the name of the View to be displayed.
// It corresponds to a file with the same name, so you can also specify
Return View ("Index ");
}
/// <Summary>
/// 3. As mentioned above, this Action is called About.
/// By default, the corresponding value is (Views/Home/About. aspx)
/// </Summary>
Public ActionResult About (){
Return View (); // 5. This is effective with return View ("About ");
}
}
}
I have already explained the relationship between Controller/Action and Views.
Note that the dashboard page is used for the website in this example.
That is, the Views/Shared/Site. Master file provides the common motherboard for other files.
How can we access these webpages?
If you are a Web developer
Http: // localhost/Views/Home/Index. aspx and
Http: // localhost/Views/Home/About. aspx