Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel Cooper 6 posts 97 karma points
    Apr 03, 2019 @ 08:31
    Daniel Cooper
    0

    Umbraco Forms Error - The asynchronous action method 'Index' returns a Task, which cannot be executed synchronously

    Hi

    I'm getting the following error on a page using Umbraco forms.

    [InvalidOperationException: The asynchronous action method 'Index' returns a Task, which cannot be executed synchronously.]
       System.Web.Mvc.Async.TaskAsyncActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +115
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
       System.Web.Mvc.<>c__DisplayClass24_0.<InvokeActionMethodWithFilters>b__0() +55
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
       System.Web.Mvc.<>c__DisplayClass24_1.<InvokeActionMethodWithFilters>b__2() +22
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
       System.Web.Mvc.<>c__DisplayClass24_1.<InvokeActionMethodWithFilters>b__2() +22
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
       System.Web.Mvc.<>c__DisplayClass24_1.<InvokeActionMethodWithFilters>b__2() +22
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +190
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +521
       System.Web.Mvc.Controller.ExecuteCore() +95
       System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +180
       System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
       Umbraco.Web.Mvc.UmbracoPageResult.ExecuteControllerAction(ControllerContext context, IController controller) +75
       Umbraco.Web.Mvc.UmbracoPageResult.ExecuteResult(ControllerContext context) +297
    

    I get it on submit of the form and, if I have multiple form pages, using the next button.

    Not sure where to start really. Any ideas?

  • Tony 105 posts 163 karma points
    Oct 21, 2019 @ 08:57
    Tony
    0

    Did you get anywhere with this? Im getting it when Im implementing custom validation on forms

  • Martina R 9 posts 90 karma points
    Oct 21, 2019 @ 15:31
    Martina R
    0

    I'm having the same problem with a custom form (not umbraco forms).

    From my understanding what is happening is that you cannot use an async [HttpGet] controller method if you want to use return CurrentUmbracoPage() as the latter is sync.

    What you could do is transform the async GET method to a sync one but that would open another can of worms since awaiting async stuff inside a sync method is dangerous and can end up in deadlocks: https://stackoverflow.com/questions/9343594/how-to-call-asynchronous-method-from-synchronous-method-in-c

    I bypassed the problem altogheter using an ajax call avoiding the 'return CurrentUmbracoPage()'...

    But I'm curious if there is a more idiomatic way to resolve the problem...

  • Tony 105 posts 163 karma points
    Dec 04, 2019 @ 12:06
    Tony
    0

    Ive noticed there is a setting in the config to make the workflow calls async, havnt played with it yet though

    <setting key="ExecuteWorkflowAsync" value="False"/>
    

    https://our.umbraco.com/documentation/Add-ons/umbracoforms/developer/Configuration/#executeworkflowasync

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies