Tag Helper vs HTML Helper “Use of IHtmlHelper.Partial may result in application deadlocks”

心不动则不痛 提交于 2019-12-13 03:34:56

问题


I have an ASP.NET Core MVC project that uses partial views. When I compile it I receive the following warning:

Use of IHtmlHelper.Partial may result in application deadlocks. Consider using Tag Helper or IHtmlHelper.PartialAsync.

What is the difference between what the Tag Helper does and what the HTML Helper does, that would cause an application deadlock?

From reading documentation here, my understanding was that the Tag Helper approach aims to make the markup easier to read and allows Intellisense support. In other words I thought the two approaches were just different syntax for the same thing, but clearly something else is going on here.

Should one always use a Tag Helper instead of a HTML Helper?


回答1:


Tag Helpers are new to ASP.NET Core and besides the advantages you have mentioned, it is worth mentioning: they are processed by Razor on the server (more robust, reliable and maintainable) and you can create your own custom TagHelpers very simply (implement the ITagHelper interface or inherit from the TagHelper class and override the Process method by defining its implementation).



来源:https://stackoverflow.com/questions/56279604/tag-helper-vs-html-helper-use-of-ihtmlhelper-partial-may-result-in-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!