Closed sussexrick closed 2 years ago
As you have noticed, this is currently not supported and I don't think there are plans to support it at this time.
It looks like we're rendering the form using a ChildAction and ChildAction's don't support async as far as I know, so it might be impossible to implement this.
I don't think Forms is the issue here, it really comes down to that we aren't properly supporting async actions for route hijacking. Using the new
keyword probably shouldn't have worked to begin with. We'd need to properly support async actions from top to bottom.
Would probably need an IndexAsync
action method to override, we'd need to modify the action resolver stuff to look for declared suffixed Async
action names, and ensure we use the async mvc actions where appropriate.
Closing this one as, as noted above, the resolution would need to happen in the CMS.
When using custom "hijacked" controllers in Umbraco we can use the async/await pattern to improve scalability. This works for most Umbraco document types, but it doesn't work with forms in Umbraco Forms 7.0.6 on Umbraco 7.13.2 (or earlier versions).
Reproduction
Create a new form with one field, and a minimal document type/template to host it. Use 'Form' as the document type alias. Add a minimal hijacked custom controller:
Test the form and it will submit.
Now change the controller to async. This requires the use of the
new
keyword because the base method returnsActionResult
but the async version needs to returnTask<ActionResult>
:Now test the form again and, as soon as you submit you get the following error in the Umbraco logs (and sometimes on screen, depending on error settings):
System.InvalidOperationException: The asynchronous action method 'Index' returns a Task, which cannot be executed synchronously.
The relevant part of the call stack for Umbraco is:
It's possible to work around this for single page forms by selecting another page in the "Go to URL" part of the submit workflow. On a multi-page form the same error occurs when navigating to page 2, and there is no obvious workaround apart from putting all fields onto one page.
Please can something be done in this method to support
async
actions that returnTask<ActionResult>
.