Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

ASP.NET MVC view


May 12, 2021 ASP.NET


Table of contents


ASP.NET MVC - View

This section describes A SP.NET MVC view, the View folder contains a folder for each controller, and each action method has a view file with the same name corresponding to it. This provides the basis for the view to be associated with the action method.

To learn ASP.NET MVC, we'll build an Internet application.

Part 5: Add a view to display the application.


Views folder

The Views folder stores files (HTML files) related to the application display (user interface). Depending on the language content used, these files may be extensions to html, asp, aspx, cshtml, and vbhtml.

The Views folder contains one folder for each controller.

In the Views folder, Visual Web Developer has created an Account folder, a Home folder, and a Shared folder.

The Account folder contains pages for user account registration and sign-in.

Home folders are used to store application pages such as home and out pages.

Shared folders are used to store views (master and layout pages) shared between controllers.

ASP.NET MVC view


ASP.NET file type

The following HTML file types can be seen in the Views folder:

file type extension name
Pure html .htm or .html
Classic ASP .asp
Classic ASP.NET .aspx
ASP.NET Razor C# .cshtml
ASP.NET Razor VB .vbhtml


Index file

The file Index.cshtml represents the Home page of the application. It is the default file (home file) for the application.

Write the following in the file:

@{ViewBag.Title = "Home Page";}

<h1>Welcome to w3cschool.cn</h1>

<p>Put Home Page content here</p>


The About file

The file, About.cshtml, represents the Out page of the application.

Write the following in the file:

@{ViewBag.Title = "About Us";}

<h1>About Us</h1>

<p>Put About Us content here</p>


Run the application

Select Debug to start debugging Start Debugging (or press F5) from the Visual Web Developer menu.

Your application will look like this:

ASP.NET MVC view

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 can't click on the "Movies" tab right now. We'll add code to the "Movies" tab later in this tutorial.