In ASP.NET MVC, a View is used to present the final output to the user in the browser.
After the Controller completes its work, it passes the required data to the View, which is then shown as a web page.
A View is a file with the .cshtml extension that contains HTML along with Razor syntax.
In simple terms, a View is responsible for showing data on the screen and does not handle request processing.
Open the required Controller.
Example: HomeController
using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Your_WebApplication_Name.Controllers { public class HomeController : Controller { // GET: Home public ActionResult Index() { return View(); } } }
Find the Action Method where you want to create the View.
public ActionResult Index() { return View(); }
Right-click on the Index Action Method.
Then click Add View.
A new window will open (MVC 5 View).
Click on the Add button.
Another window will open where you can:
Available Templates:
Click on the Add button.
Auto Generated Code
@{ ViewBag.Title = "Index"; } <h2>Index</h2>
https://localhost:44300/Home/Index