Copied to clipboard

Flag this post as spam?

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


  • Adriano Fabri 459 posts 1602 karma points
    Mar 20, 2017 @ 09:20
    Adriano Fabri
    1

    Problems with ModelState.IsValid in a UmbracoPage with params

    Hi, I have some problems when I validate the Model in a page managed by your package. This is the scenario.

    I have an umbraco page with 3 parameters (umbracoParam) - The node url is Admin. In a sub virtual page I need to create a form to modify a product (URL: "Admin/home/bath/1000 - where home, bath and productId are the parameters).

    Now I need to validate the form...but when the Model is invalid I cannot return on current page with params and modified model data.

    I tried with no result with:

    • return CurrentUmbracoPage();
    • return RedirectToCurrentUmbracoUrl();
    • return RedirectToCurrentUmbracoPage();

    Usually with forms I used "return CurrentUmbracoPage();", but in this case I return on the Umbraco Page "Admin" without the params.

    How can I solve this problem? Have you realize a custom method to do it?

    Thank you in advance. Adriano

  • Jonathan Richards 288 posts 1742 karma points MVP
    Mar 20, 2017 @ 10:48
    Jonathan Richards
    0

    Hi Adriano

    Sadly there is nothing in AutoRouteTemplate that keeps the original Url (admin/home/bath/1000), so that you can redirect back to it when forms error.

    You will have to roll your own solution. The best I can think of is saving the original Url to either a hidden text field in your form or use the Session (HttpContext.Session) object.

    Cheers

    Jonathan

Please Sign in or register to post replies

Write your reply to:

Draft