Use of await in Razor views

前端 未结 8 884
面向向阳花
面向向阳花 2020-11-28 12:48

Is it possible to await on tasks in Razor .cshtml views?

By default it complains that it can only be used in methods marked with async so I

8条回答
  •  感情败类
    2020-11-28 12:53

    In ASP.NET Core 2.1, you can use await in Razor views.

    See https://docs.microsoft.com/en-us/aspnet/core/mvc/views/partial?view=aspnetcore-2.1

    Example:

    @await Html.PartialAsync("../Account/_LoginPartial.cshtml")
    

提交回复
热议问题