Search w3schools.com:

SHARE THIS PAGE

ASP.NET MVC - Views


To learn ASP.NET MVC, we are Building an Internet Application.

Part V: Adding Views for Displaying the Application.


The Views Folder

The Views folder stores the files (HTML files) related to the display of the application (the user interfaces). These files may have the extensions html, asp, aspx, cshtml, and vbhtml, depending on the language content.

The Views folder contains one folder for each controller. 

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

The Account folder contains pages for registering and logging in to user accounts.

The Home folder is used for storing application pages like the home page and the about page.

The Shared folder is used to store views shared between controllers (master pages and layout pages).

 Views


ASP.NET File Types

The following HTML file types can be found in the Views Folder:

File TypeExtention
Plain HTML.htm or .html
Classic ASP.asp
Classic ASP.NET.aspx
ASP.NET Razor C#.cshtml
ASP.NET Razor VB.vbhtml


The Index File

The file Index.cshtml represents the Home page of the application. It is the application's default file (index file).

Put the following content in the file:

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

<h1>Welcome to W3Schools</h1>

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


The About File

The file About.cshtml represent the About page of the application.

Put the following content in the file:

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

<h1>About Us</h1>

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


Run the Application

Select Debug, Start Debugging (or F5) from the Visual Web Developer menu.

Your application will look like this:

MVC Application

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 the next chapters of this tutorial.




W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The HTML5 Certificate documents your knowledge of advanced HTML5.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]