Previous Article: ASP. net mvc Tutorial: create the first MVC application
BKJIA quick translation]
Sample ASP. net mvc application
Use the default Visual Studio template to create ASP. net mvc Web applications, a very simple instance program will be created along with, can be used to help understand ASP.. net mvc program, this article will use this example to explain.
In Visual Studio 2008, click "file"> "Create Project" and select "ASP. net mvc "template to create an ASP. net mvc application, as shown in 1. In the Create Project dialog box, select a programming language that you are familiar with under the project type, such as Visual Basic or C #, and then select "ASP. net mvc Web Application Template, click OK.
Figure1Create Project dialog box
You are creating a new ASP. net mvc application, a new unit test project creation dialog box is displayed, as shown in 2. This dialog box allows you to create a project for your solution to test your ASP.. net mvc application. Select "No, do not create a test project" and click "OK.
Figure2Create unit test dialog box
Create ASP. net mvc application, you will see Several folders and files in the solution browsing window. In particular, you will see three folders: Model Models, view Views, and controller Controllers, as you have guessed from the names of these folders, these folders include model, view, and controller implementation files.
If you expand the Controller folder, you will see a file named HomeController. vb file. If you expand the view folder, you will see two subfolders: Home and Shared. If you expand the Hom folder, you will see two files: about. aspx and Home. aspx3 ). These files constitute Applications created using the default ASP. net mvc template.
Figure3Solution browsing window
By selecting the menu item "debug"> "start debugging", you can run this sample program. Similarly, press F5.
When you run the ASP. net mvc application for the first time, the dialog box shown in Figure 4 is displayed. We recommend that you enable the debugging mode and click OK to start running the program.
When you run an ASP. net mvc application, Visual Studio starts the application in your browser. The sample application consists of two pages: The Index page and the About page. The Index page 5 is displayed when the application is started for the first time. You can click the link in the upper-right corner of the application to switch to the About page.
Figure4Debug not enabled dialog box
Note the URL in the address bar of the browser. When you click the Home link, the URL in the address bar of the browser changes to/Home. When you click the About link, the URL is changed to/About.
If you close the browser and return to the Visual Studio window, you cannot see the Home and About files exist. How can this problem be solved?