Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • James 23 posts 156 karma points
    Oct 21, 2019 @ 03:43
    James
    1

    Loosing modelstate in surface controller

    I have a form that submits to a surface controller from a partial.

    If I add an error and return CurrentUmbracoPage () I loose all my model state.

    View:

    @Html.Partial("Forms/FormView", new FormModel())

    Partial:

    @using (Html.BeginUmbracoForm("Endpoint", "FormSurface", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
    
    }
    

    Surface controller:

       public class FormSurfaceController : Umbraco.Web.Mvc.SurfaceController
        {
    
            [System.Web.Mvc.HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult Endpoint(FormModel model) {
    
        return CurrentUmbracoPage();
    

    This returns me to the form, but all the data is lost.

    Not sure what is wrong I have followed the tutorial and viewed forums and my code looks to be correct.

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft