System.Threading.Tasks.Task`1 [System.Web.Mvc.ActionResult]而不是登录和注册用户时查看

时间:2015-08-23 18:57:55

标签: c# asp.net-mvc asp.net-mvc-5

下面的代码在MVC中登录并注册用户时收到错误System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult]而不是查看:

public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    if (!ModelState.IsValid)
    {
        return View(model);
    }

    var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

    switch (result)
    {
        case SignInStatus.Success:
            return RedirectToLocal(returnUrl);
        case SignInStatus.LockedOut:
            return View("Lockout");
        case SignInStatus.RequiresVerification:
            return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
        case SignInStatus.Failure:
        default:
            ModelState.AddModelError("", "Invalid login attempt.");
        return View(model);
    }
}

尝试登录时收到错误System.Threading.Tasks.Task1[System.Web.Mvc.ActionResult]而不是查看。 注册用户时出现相同的错误。

public async Task<ActionResult> Register(RegisterViewModel model)
{
    if (ModelState.IsValid)
    {
        var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
        var result = await UserManager.CreateAsync(user, model.Password);
        if (result.Succeeded)
        {
            await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);

            return RedirectToAction("Index", "Home");    
        }

        AddErrors(result);
    }

    return View(model);
}

0 个答案:

没有答案