Copied to clipboard

Flag this post as spam?

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

  • Bryan Noriega 4 posts 35 karma points
    1 week ago
    Bryan Noriega

    Umbraco Route Hijacking with Surface Controller

    Hi all,

    Let see if someone can give me a hand with an issue I'm having in umbraco 9.

    I'm doing route hijacking to populate a model with some information that is added in a custom area in umbraco and not the actual node. This is working perfectly fine and the page is being redered and the model is being populated.

    The issue comes because I have a form there to logout and another to dowload some files both of them are using a surface controllers to control the POST. When I submit these forms the controller POST method is never reached and I'm getting the following error:

    "ModelBindingException: Cannot bind source type Umbraco.Cms.Core.Models.ContentModel to model type Carrington.Web.Models.FabricDetailViewModel."

    Being "FabricDetailViewModel" the model used in the hijack and on the view.

    Is there away to have forms on views that are loaded via hijacking?

    Thanks in advance!

  • Marc Goodson 1718 posts 11412 karma points MVP 7x c-trib
    5 days ago
    Marc Goodson

    Hi Bryan

    Can you post your SurfaceController and form?

    The form needs to be wired up to post to the SurfaceController action, and then from the SurfaceController you can check validation of form - insert entries to a database, send an email, or some other action etc etc, Then you 'redirect' back to either the CurrentPage or another Umbraco Thank You Page, where the RouteHijacking occurs and builds up your ViewModel to render the page...

    ... it sounds like the form is trying to post to the hijacked controller, (that's just a guess! - which if so, that isn't how it's designed to work)



Please Sign in or register to post replies

Write your reply to: