Javatpoint Logo
Javatpoint Logo

ASP.NET MVC View

The MVC View is a standard HTML page that may contain script. It is used to create web pages for the application. Unlike ASP.NET Web Pages, MVC Views are mapped to the action and then controller renders the view to the browser.

MVC has certain conventions for project structure. The view file should be located in the subdirectory of View folder.

MVC uses Razor view engine so that we can write server side code in HTML as well. Let's create a view and execute it to the browser.


Creating View to the Application

To add view, right click on the subfolder inside the View folder and select Add-> Add View. It will pop up for the view name etc.

ASP View 1

This file has following default code.

// Welcome.cshtml

If we want to execute it, we have a controller like this:

This controller has Welcome action method that will render Welcome view file to the browser. Right click on the Welcome.cshtml file and select view in browser. This will produce the following output.

Output:

ASP View 2




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA