In the Model-View-Controller (MVC) pattern, the view handles the application’s data presentation and user interaction. A view is an HTML template with embedded Razor markup. Razor markup is code that interacts with HTML markup to produce a web page that’s sent to the client.
- In ASP.NET MVC, views are .cshtml files that use the C# programming language in Razor markup.
Let’s start by creating a controller:
In Solution Explorer, right click on the Controllers folder and click on Add then Controller like this:
In the Add Scaffold dialog box, click MVC 5 Controller – Empty then Add:
Name your new controller “AboutUsController” and click on Add button:
- Now, you will get a controller and a view folder in your Solution Explorer.
- Let us add a view to this controller that will act as a data presentation and user interaction page.
Right click on the “ActionResult Index ()”and click Add view:
- In the Add View window, use the layout (if you have any).
- Click on Add button.
You should see a view created in the “AboutUs” folder like this:
Build your project and you can view your new view / page by going to this URL:
http://localhost:#####/AboutUs/ where ##### represents the port number.
Visit DiscountASP.NET to learn more about our ASP.NET MVC hosting solutions
About Guest Blogger: Lavish Kumar
Based out of New York, USA, Lavish Kumar is a full stack web developer by profession and founder of Striving Programmers, a trusted community for developers that offers a wealth of articles and forums to assist individuals with improving their software development skills. He is passionate about writing tech articles and building great web applications. Lavish specializes in custom web applications, e-Commerce platforms, CMS implementation and CRM systems.