Copied to clipboard

Flag this post as spam?

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


  • Greg 1 post 21 karma points
    Nov 20, 2013 @ 13:34
    Greg
    0

    Posting data to a hijacked controller

    Hi

    I'm new to Umbraco (and the world of CMS in general), so please forgive any questions that may seem obvious.

    I've created a custom controller for one of my document types in order to populate some data needed when the view renders initially i.e. in the Index() action.

    Everything is working fine so far: I've inherited from RenderMvcController, populated a model inside the Index() method, passed it on to the view and have the view rendering it.

    I'm now trying to get data POSTed back to the same custom controller and this is where I'm hitting problems. I've used SurfaceControllers without problems in other pages in my site, but my theory is that since I have already defined a controller for this page I don't want to have to define a "2nd" controller just to handle posting data - I'd like to keep everything in one place.

    This doesn't seem to be possible though? All of the googling I've done so far says to use SurfaceControllers (I've done this, and it works fine), but that means I will in effect have 2 controllers for this page?

    I have also found some links suggesting using a custom route, but from my understanding that means I will have to use Html.BeginForm() and not Html.BeginUmbracoForm() - since BeginUmbracoForm() will auto route to surface controllers.

    I found one brief mention about having your customer controller inherit from SurfaceController and implement IRenderMvcController, but I'm not sure where to begin on that.

    So my question is: what (if any) is the correct way of POSTing data back to a custom controller? Don't and use a SurfaceController instead? Use a custom route? Or inherit from SurfaceController and implement IRenderMvcController?

    Cheers Greg

  • Dan Mothersole 22 posts 109 karma points
    Dec 05, 2013 @ 15:15
    Dan Mothersole
    0

    Hi,

     

    I think you need to use surface controlers, I don't see the need for two controllers I just wrap all my login into the 1 surface controller.

     

    http://our.umbraco.org/documentation/Reference/Mvc/surface-controllers

Please Sign in or register to post replies

Write your reply to:

Draft