Search⌘ K
AI Features

Views and Tag Helper

Explore the role of views in ASP.NET Core MVC, focusing on the Razor view engine and how it renders models into HTML. Understand how to use Tag Helpers to create navigation links and enhance web pages with dynamic content. Learn techniques like cache busting for scripts and styling integration with Bootstrap to build scalable and maintainable websites.

In MVC, the V stands for view. The responsibility of a view is to transform a model into HTML or other formats. Multiple view engines could be used to do this. The default view engine is called Razor, and it uses the @ symbol to indicate server-side code execution. The Razor Pages feature introduced with ASP.NET Core 2.0 uses the same view engine and can use the same Razor syntax.

Rendering the lists of categories

Let’s modify the home page view to render the lists of categories and products:

Step 1: Expand the Views folder, and then expand the Home folder.

Step 2: Open the Index.cshtml file and note the block of C# code wrapped in @{ }. This will execute first and can be used to ...