When Does EPiServer validate XFormPostedData



I'm not having much luck in trying to figure this out. We're on EPiServer 7.5 and I am posting a form from a Block by using code similar to that found here http://cjsharp.com/blog/2013/04/11/creating-a-xform-block-in-episerver-7-mvc-with-working-validation-updated/. This all works okay but in my XFormPost method I want to check if the ModelState is valid before I do anything else.



        public virtual ActionResult XFormPost(XFormPostedData xFormpostedData)
            ActionResult thisResult;

            if (Request.UrlReferrer == null || string.IsNullOrEmpty(Request.UrlReferrer.Query) || !this.ModelState.IsValid)
                thisResult = _xformHandler.HandleAction(this);
                return thisResult;

            // Do other stuff

At this point the ModelState is always true. If I run _xformHandler.HandleAction(this) it seems to set the ModelState correctly but I don't really know what else this does. For example I don't want it to post the form data. Can anyone clarify what the HandleAction method does and if there is another (more correct way) of validating the model at this point?

Thanks in advance!

Aug 17, 2018 16:23

It looks like the following command will validate the model:


Aug 20, 2018 10:03
* 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.