你还在用Html.PartialAsync? 教你更简单一招搞定

   我们在使用Core开发时遇到使用@Html.Partial(“ActionName”);时,编译器会出现如下警告:

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

  那么有意思了,我开始百度这个错误内容,查到的解决方案全部都是,使用

@await Html.PartialAsync(“ActionName”);

  查到这里我的内心是有点崩溃的,2020年了兄弟们,咱们就不能有点钻研精神,警告里大大的写着 Consider using <partial> Tag Helper,那么<partial> Tag到底怎么用?为什么没人用?因为懒,有现成答案,不会用。于是查到微软的官方文档,下面给出链接:

  https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/partial-tag-helper?view=aspnetcore-3.1

  清清楚楚写着,一个partial标签解决所有难题,于是改为如下:

<partial name="ActionName" />

  简单清晰明了。运行,完美。

原文地址:https://www.cnblogs.com/cnwhm/p/12371850.html