Skip to main content

Posts

Showing posts with the label which cannot be executed synchronously.

Asynchronous Action Method Returns a Task, which cannot be Executed Synchronously

The error as given below. System.InvalidOperationException' occurred in System.Web.Mvc.dll but was not handled in user code. Additional information: The asynchronous action method 'Login' returns a Task, which cannot be executed synchronously. The solution for the above error as given below in details . Firstly, I have changed the application running process [5228] iisexpress.exe to [3840] ieexpoler.exe and run the application, error is resolved. And the Second step below code changed. var rc = new RequestContext( new HttpContextWrapper(Context), routeData); controller.Execute(rc); Replace above code by given below code. (( IController )controller).Execute( new RequestContext(new HttpContextWrapper(HttpContext.Current), routeData)); And In the 3rd Steps changed the name of login action         [HttpPost]         [AllowAnonymous]       ...