Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Episerver Forms multiple issues on Form Submit, subsequent page reloads with the form and recaptcha block


Issue 1: Form on first submit, displays form submission completed with form fields still shown rather hidden. 

Issue 2: Form on page reload throws 500 exception where the exception throw with the message below , where the currentBlock on subsequent page reload return null. 

  Message=Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.
  Source=<Cannot evaluate the exception source>
<Cannot evaluate the exception stack trace>

Inner Exception 1:
EPiServerException: ContentReference: Input string was not in a correct format.

Issue 3: 

After installing RecaptchaBlock via Episerver.Forms.Samples, getting 400 on scripts 

"{0}", SiteKey

And I am using Recaptcha V2 TickBox

Please help me out in overcoming these issues

Jul 26, 2021 7:45

For issue 1 - there seem to be a bug in the form handler on the server side, there is a field controlling  the multi-step forms that get set to -1 instead of 0 after posting the form once, we solved it like so:

    /// <summary>
    /// This circumvent a bug where the second time a form is posted, the __FormCurrentStepIndex value is -1, instead of the default 0, which causes an error in the data submit function.
    /// </summary>
    public class  CustomDataSubmissionService : EPiServer.Forms.Core.Internal.DataSubmissionService
        public override SubmitActionResult PerformDataSubmit(NameValueCollection rawSubmittedData, HttpContextBase httpContext, ControllerBase controller)
            // the incoming collection is readonly, copy it
            var col = new NameValueCollection(rawSubmittedData);
            // the current form step should never be -1, so set it to 0 if it is submitted as such
            if(col["__FormCurrentStepIndex"] == "-1") {
                col["__FormCurrentStepIndex"] = "0";

            return base.PerformDataSubmit(col, httpContext, controller);

And then use the custom service in your service container setup:

context.Services.AddSingleton<DataSubmissionService, CustomDataSubmissionService>();
Sep 01, 2021 9:42

Thanks for this solution!

Sep 20, 2021 12:20
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.