MVC4 .NET 4.5 async action method does not redirect

前端 未结 2 1506
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 08:57

I am trying to implement a task action method in my MVC 4 application. Everything works on the back in, but it is not redirecting.



        
2条回答
  •  伪装坚强ぢ
    2020-12-10 09:12

    I was able to get it working after making the Action I was directing it to an async action as well. I am guessing if you have any async action method redirecting to another then that redirect must be async as well.

    Here is just a quick example

    public async Task Login(LoginModel model) {
        //You would do some async work here like I was doing.
    
        return RedirectToAction("Action","Controller");//The action must be async as well
    }
    public async Task Action() {//This must be an async task 
        return View();
    }
    

提交回复
热议问题