Reputation: 1592
I have an action as follows:
public async Task<ActionResult> Pair(string id)
{
try
{
DocuSignAPIManager docuSignAPIManager = new DocuSignAPIManager();
DocuSignEsignatureAuthContainer authContainer = await docuSignAPIManager.Pair(User.Identity.Name, id).ConfigureAwait(false);
DocuSignManager.Instance.Pair(User.Identity.Name, authContainer);
}
catch(Exception e)
{
ErrorManager.Instance.LogError(e);
}
return new HttpStatusCodeResult(200);
}
When the action is called all of the logic is executed, however instead of an HTTP Status 200 code, I receive the following:
System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult]
For testing I'm just calling the action from a web browser using the following URL:
http://localhost:20551/CharteredSurveyor/Pair/password
I really don't understand what the problem is - can anyone help?
Upvotes: 5
Views: 3936
Reputation: 2824
This worked for me,
changing
public class authController : Controller
to
public class authController : AsyncController
I made the controller class that contains the async action that gave that error inherit from AsyncController class instead of the default Controller class
I found that answer here
Upvotes: 0
Reputation: 4783
The ErrorHandlingControllerFactory
from ELMAH returns a custom action invoker which it uses to make sure its HandleErrorWithElmahAttribute
is applied to the controller. It never supplies an async action invoker so it doesn't understand async/await.
Two workarounds;
ControllerBuilder.Current.SetControllerFactory(new ErrorHandlingControllerFactory())
and simply add HandleErrorWithElmahAttribute
to the global filters using GlobalFilters.Filters.Add(new HandleErrorWithElmahAttribute());
Cheers, Dean
Upvotes: 3