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

Trying to make a web app using .Netcore When I run the application I get this error. Help me This is not a errors but a warning. But help me to resolve

I added my code below

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>

    <link href="~/css/bootstrap.css" rel="stylesheet" />
    <link href="~/css/sidebar-nav.min.css" rel="stylesheet" />
    <link href="~/css/animate.css" rel="stylesheet" />
    <link href="~/css/default.css" rel="stylesheet" />
    <link href="~/css/style.css" rel="stylesheet" />
</head>
<body class="fix-header fix-sidebar">
    <div id="wrapper">
        @Html.Partial("AdminPartials/_TopMenu")
        @Html.Partial("AdminPartials/_Sidebar")
        <div id="page-wrapper" style="min-height:600px">
            <div class="container-fluid">
                @RenderBody()
                <hr />
                <footer class="footer text-center">© @DateTime.Now.Year | Powered by Techguy</footer>
            </div>
        </div>
    </div>

    @RenderSection("scripts", required: false)

    <script src="~/js/jquery.min.js"></script>
    <script src="~/js/bootstrap.min.js"></script>
    <script src="~/js/sidebar-nav.min.js"></script>
    <script src="~/js/custom.js"></script>

</body>
</html>


Solution 1:[1]

In case you are looking just how to update from @Html.Partial to <partial>:

    @Html.Partial("AdminPartials/_TopMenu")
    @Html.Partial("AdminPartials/_Sidebar")

Should be changed to

    <partial name="AdminPartials/_TopMenu" />
    <partial name="AdminPartials/_Sidebar" />

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

Solution 2:[2]

For the ones how as me are not so familiar with regex. You can do this change easily in whole solution using Find&Replace. It should do the job in most cases.

Find: \@Html.Partial\(\"(.*?)\"\),

Replace: <partial name="$1" />,

option "Use regular expressions" checked

and

Find: \@Html.Partial\(\"(.*?)\", (.*?)\),

Replace: <partial name="$1" for="@($2)"/>,

option "Use regular expressions" checked

Solution 3:[3]

use

@await Html.PartialAsync("_partialView", new List<Model>())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Konard
Solution 2
Solution 3 AAI INGENIERIA