How to do it...

The goal of TagHelpers is to reduce the writing of the views using HTML tags and/or attributes interpreted by Razor. They replace HTMLHelpers with the closest syntax of HTML, allowing integrators to work with MVC views more easily:

  1. First, let's add an Insert action method for GET and POST in HomeController.cs, and let's add a break point on the Insert method of POST:
  1. Next, let's add the Insert view with TagHelper code for an input to test TagHelpers:
  • We can see the asp-for TagHelper added to the input text HTML element. ...

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.