What is the difference between partial
tag helper implemented in .net core 2.1:
<partial name="_AuthorPartial" />
and
@await Html.PartialAsync("_AuthorPartial")
Which one should I use in the production and what are the benefits?
Tag Helpers are attached to HTML elements inside your Razor views and can help you write markup that is both cleaner and easier to read than the traditional HTML Helpers. HTML Helpers, on the other hand, are invoked as methods that are mixed with HTML inside your Razor views.
HtmlHelper is a class which is introduced in MVC 2. It is used to create HTML controls programmatically. It provides built-in methods to generate controls on the view page. In this topic we have tabled constructors, properties and methods of this class.
What are Tag Helpers. Tag Helpers enable server-side code to participate in creating and rendering HTML elements in Razor files. For example, the built-in ImageTagHelper can append a version number to the image name.
The short answer is that there isn't a difference when it comes to how the server handles them. The end result is exactly the same from a server perspective.
There are some benefits (from a developer's perspective) listed here that are worth noting, specifically the improved Intellisense that they provide.
In my experience, Tag Helpers are also easier for UI designers to read and use as they look and feel more like HTML than Html Helpers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With