Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between partial tag helper and HTML helper in asp.net core?

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?

like image 391
GoldenAge Avatar asked Sep 12 '18 22:09

GoldenAge


People also ask

What is the difference between tag helper and HTML helper?

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.

What is HTML helpers in ASP.NET Core?

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 is HTML tag helpers?

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.


1 Answers

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.

like image 81
Chris.ZA Avatar answered Oct 08 '22 20:10

Chris.ZA