Description
Feature request
In all our on-boarding tutorials (MVC and Razor Pages), new programmers are introduced to both Tag Helpers and HTML Helpers. HTML Helpers are especially complicated. See the Index.cshtml Razor Page
What follows is the complicated explanation of the lambda expression used in the HTML Helper:
Examine the lambda expression used in the following HTML Helper:
@Html.DisplayNameFor(model => model.Movie[0].Title))
The DisplayNameFor
HTML Helper inspects the Title
property referenced in the lambda expression to determine the display name. The lambda expression is inspected rather than evaluated. That means there is no access violation when model
, model.Movie
, or model.Movie[0]
are null or empty. When the lambda expression is evaluated (for example, with @Html.DisplayFor(modelItem => item.Title))
, the model's property values are evaluated.
I was forced to add the lambda explanation because of so many customer questions.
The very next section on the Create Razor Page is all Tag Helpers.
I recommend adding Tag Helpers (TH) to replace all the HTML Helpers that are scaffolded. The scaffolder will need to use the new TH's. This will significantly lower the barrier to entry. New developers can focus on THs and not be forced to learn HTML Helpers simultaneously.
The intro tutorials generate a lot of issues because of the complexity of HTML Helpers. For example, Confusing example of DisplayFor