public async Task <IActionResult> Index( string form, string path, Dictionary <string, string[]> formData, IEnumerable <CustomFormFile> fileUpload, string subPath = "") { var viewModel = formData.ToNormaliseDictionary(subPath); if (fileUpload != null && fileUpload.Any()) { viewModel = _fileUploadService.AddFiles(viewModel, fileUpload); } var currentPageResult = await _pageService.ProcessRequest(form, path, viewModel, fileUpload, ModelState.IsValid); if (currentPageResult.RedirectToAction && !string.IsNullOrWhiteSpace(currentPageResult.RedirectAction)) { return(RedirectToAction(currentPageResult.RedirectAction, currentPageResult.RouteValues ?? new { form, path })); } if (!currentPageResult.Page.IsValid || currentPageResult.UseGeneratedViewModel) { return(View(currentPageResult.ViewName, currentPageResult.ViewModel)); } if (currentPageResult.Page.HasPageActionsPostValues) { await _actionsWorkflow.Process(currentPageResult.Page.PageActions.Where(_ => _.Properties.HttpActionType == EHttpActionType.Post).ToList(), null, form); } var behaviour = _pageService.GetBehaviour(currentPageResult); switch (behaviour.BehaviourType) { case EBehaviourType.GoToExternalPage: return(Redirect(behaviour.PageSlug)); case EBehaviourType.GoToPage: return(RedirectToAction("Index", new { path = behaviour.PageSlug })); case EBehaviourType.SubmitForm: return(RedirectToAction("Submit", new { form })); case EBehaviourType.SubmitAndPay: var result = await _paymentWorkflow.Submit(form, path); return(Redirect(result)); default: throw new ApplicationException($"The provided behaviour type '{behaviour.BehaviourType}' is not valid"); } }