System.Threading.Tasks.Task`1[Microsoft.AspNet.Mvc.Rendering.HtmlString] in place of Html.PartialAsync

System.Threading.Tasks.Task`1[Microsoft.AspNet.Mvc.Rendering.HtmlString] showed in my cshtml page where partial views were supposed to render. This was after upgrading to asp.net core 3.1 and going through the warnings that said Html.Partial should be replaced with Html.PartialAsync now to prevent deadlocks. Great, I’ll just go replace them all… blindly, because that’s how I roll.
This resulted in the System.Threading.Tasks.Task`1[Microsoft.AspNet.Mvc.Rendering.HtmlString] appearing in the page – what the.
So you actually need to add await to the code when changing to the PartialAsync – so your call would look like this now:

@async Html.PartialAsync()

instead of the old way:

@Html.Partial()

Leave a Reply

Your email address will not be published. Required fields are marked *