简体   繁体   中英

Use of Redirect in Async and Await Method

I am facing a problem, I am not able to redirect to some another page by using the await call.

I have been searching for two days but i am not getting the solution. Following is my code:

 public async Task<ActionResult> Login(string returnUrl)
 {
      try
      {
          if (Url.IsLocalUrl(returnUrl))
          {
               Response.Redirect(returnUrl, false);
          }
      }
 }

Calling Method:

public async Task<ActionResult> GotoLogin()
{
    if (ModelState.IsValid)
    {
        await Login("/myhome");
    }
}

Do you need to direct the user to the "myHome" controller? try RedirectToAction,

return RedirectToAction("myHome", "Home", new { area = "Home"});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM