Why is this returning System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult]

asp.net-mvc-4

Solution

Was this project upgraded from a prior version? Check that any libraries you're referencing are not referencing an old version of MVC as a dependency. To fix this exact issue I...

Removed the following from my web.config:

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

Ensured targetFramework is .NET 4.5

<compilation debug="true" targetFramework="4.5">

And removed a reference to the library Fluent Filters which was a legacy solution for global filters.

With those changes I was able to return a task from a controller.

Problem

Not sure why this is not returning my view after the task is completed and I can find much on Google as to why. ``` public async Task<ActionResult> GetUserAsync() { var value = Task.Factory.StartNew(() => _userService.GetUser("ausername")); await Task.WhenAll(value); return View("GetUser"); } ```

Original source