ASP.NET MVC - Views
To learn ASP.NET MVC, we will build an Internet application.
Part 5: Adding Views to Display the Application.
Views Folder
The Views folder stores files related to the application's display (user interface), such as HTML files. Depending on the language used, these files may have extensions like html, asp, aspx, cshtml, and vbhtml.
The Views folder contains a folder for each controller.
Within the Views folder, Visual Web Developer has already created an Account folder, a Home folder, and a Shared folder.
The Account folder contains pages for user account registration and login.
The Home folder is used to store application pages like the home page and about page.
The Shared folder is used to store views (master pages and layout pages) shared between controllers.
ASP.NET File Types
In the Views folder, you can find the following HTML file types:
File Type | Extension |
---|---|
Plain HTML | .htm or .html |
Classic ASP | .asp |
Classic ASP.NET | .aspx |
ASP.NET Razor C# | .cshtml |
ASP.NET Razor VB | .vbhtml |
Index File
The Index.cshtml file represents the application's Home page. It is the default file (main page) of the application.
Enter the following content in the file:
About File
The About.cshtml file represents the application's About page.
Enter the following content in the file:
Running the Application
Select Debug, and start debugging from the Visual Web Developer menu (or press F5).
Your application will display as follows:
Click on the "Home" tab and the "About" tab to see how it works.
Congratulations
Congratulations. You have created your first MVC application.
Note: You cannot click on the "Movies" tab yet. We will add code for the "Movies" tab in later sections of this tutorial.