Home > Back-end >  c# mvc todo list Use of IHtmlHelper.Partial may result in application deadlocks
c# mvc todo list Use of IHtmlHelper.Partial may result in application deadlocks

Time:04-02

/Users/fevzisahinler/Projects/Todo/Todo/Views/Shared/_Layout.cshtml(14,14): Warning MVC1000: Use of IHtmlHelper.Partial may result in application deadlocks. Consider using <partial> Tag Helper or IHtmlHelper.PartialAsync. (MVC1000) (Todo)

please help me

I created _form.cshtml file under shared,

inside _layout.cshtml @Html.Partial("_Form") I added @Html.Partial("_Form") to the section so that it appears on the homepage but I get an error

CodePudding user response:

According to the documentation:

Rendering a partial using IHtmlHelper.Partial or IHtmlHelper.RenderPartial extension methods results in blocking calls. This may result in performance degradation and application dead locks issues due to thread pool starvation.

Meaning that if you use @Html.Partial, you can have performance issues because this call is synchronous.

So, in your case, it should be:

@await Html.PartialAsync("_Form")

Or... if you want to use the tags, you can do:

<partial name="_Form" />

These 2 options are asynchronous so your error should go away.

  • Related