What is the advantage of using Tag Helpers in ASP.NET Core?

Asked

Viewed 392 times

4

I am studying the ASP.NET Core and came across the tag helpers when I ran the scaffold of a view. I found interesting the new syntax, the code is more readable at some points, however, the inclusion of another DLL in all views that the tag helpers cannot end up weighing in the project?

What other advantages or disadvantages can be highlighted in relation to tag helpers?

Obs.: Searching a little on Google found this topic on Soen, but I found it interesting to keep the question to have a discussion on the subject in Portuguese.

1 answer

5


In general this extra weight is not significant and in the background if not using the weight may even be greater in some cases.

The main advantage you have already noticed is the readability of the code. This has to do with better abstraction. It also helps to be encapsulated and to make it easy to change some detail of the final HTML code without having to touch every page. Great for evolving HTML within new standards and practices. Remember that the tag helper is a method, it has all the benefits of this code building element.

The main drawback is that you lose control of the code to be used. If the helper is very specific or very general, it makes it useless for most cases, so it is difficult to find a balance than put in his code. For simple things it is easy to use. Some settings are possible, although limited, if the helper specific is built thinking about it. Although this may start to complicate the code and send readability to space.

They may not interact well with all constructions of view. This depends on the quality of the helper, but you can’t work miracles.

Like all resources if you do not know how to use it properly, know how to use creativity so that it is really useful, it is better not to use. Of course using existing ones should not be a problem, but create your own helpers requires a little experience to not make mistakes and decrease their usefulness.

Kind of reminds the web Components.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.