MVC - 异步任务<partialviewresult>

时间:2017-08-15 10:02:14

标签: asp.net-mvc async-await

如何将子动作(渲染部分)调用到_layout? MVC不支持部分视图的异步?

public async Task<PartialViewResult> _Notification()
{
    var data = new List<UserNotification>();
    string apiNotificationUrl = APIProvider.APIGenerator("UserNotification", new List<string> { "UID" }, true, _userSession.UID);
    try
    {
        //data = await Task.Run(() => APIProvider.Authorize_Get<List<UserNotification>>(_userSession.Token, apiNotificationUrl));
        data = await APIProvider.Authorize_Get<List<UserNotification>>(_userSession.Token, apiNotificationUrl);
        if (data == null) new List<UserNotification>();
    }
    catch (Exception ex)
    {
        throw;
    }
    return PartialView(data);
}

查看

@Html.Action("_Notification", "Home")

0 个答案:

没有答案