__RequestVerificationToken value is not being set on first load of page, which results in an error 500: HttpAntiForgeryException
On first load the cookie is present but with and empy value then on reload of the page the value gets set and now the form submission works.
I have removed the [ContentOutputCache] from the PageController and the <%= Html.GenerateAntiForgeryToken(Model) %> is present in the FormContainerBlock.ascx file.
Exception type - System.Web.Mvc.HttpAntiForgeryException
Failed method - EPiServer.Forms.Internal.Security.AntiForgeryService.Validate
Log:
System.Web.Mvc.HttpAntiForgeryException:
at EPiServer.Forms.Internal.Security.AntiForgeryService.Validate (EPiServer.Forms, Version=4.29.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7)
at EPiServer.Forms.Controllers.DataSubmitController.Submit (EPiServer.Forms, Version=4.29.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7)
at lambda_method (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.Mvc.ReflectedActionDescriptor.Execute (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12 (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Controller.ExecuteCore (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.ControllerBase.Execute (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at EPiServer.Forms.Controllers.FormsMvcHandler.ProcessController (EPiServer.Forms, Version=4.29.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7)
at EPiServer.Forms.Controllers.FormsMvcHandler.BeginProcessRequest (EPiServer.Forms, Version=4.29.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7)
at System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication+<>c__DisplayClass285_0.<ExecuteStepImpl>b__0 (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication.ExecuteStepImpl (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication.ExecuteStep (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)