You must Sign In to post a response.
  • Category: ASP.Net MVC

    Error while redirecting in mvc

    Hi Team,

    i am using VS2012 and when we are login and registering the users in mvc getting below error.

    System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult] instead of view.
  • #761737
    Can you share your code.

    I think you are making "async" but, you are not handling the "await "

    By Nathan
    Direction is important than speed

  • #761740
    Hi sandip.

    I didn't understand what you mean "when we are login and registering the users in mvc"

    Give more details regarding your issue. so that anyone help you.


    Sridhar Thota.
    If you learn't from defeat..
    You haven't really lost..

    Sridhar Thota.
    Editor: DNS Forum.

  • #761742
    Below is code
    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).ConfigureAwait(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:

    ModelState.AddModelError("", "Invalid login attempt.");
    return View(model);

    when trying to login getting error 'System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult]' instead of view.
    Same error while registering users.

    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");

    return View(model);

Sign In to post your comments