Copied to clipboard

Flag this post as spam?

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


  • Damian Green 452 posts 1433 karma points
    Jan 29, 2014 @ 15:04
    Damian Green
    0

    Best way to redirect to another surface controller action in a multi step process?

    i.e. Step1, Step2, Step3

    and make it so you can go backwards and forwards via steps?

    Each step has a GET (child action) and partial and a POST Action and if the form is valid needs to go to the next Step action or back to the previous step.

    I could do this using the umbraco redirect but id like to set a query string to allow a page to be refreshed if the user presses F5 for example.  Without a querystring I cant get the id of the data to load - it just starts with a fresh page. And I also dont really want to use session as they may want more that one window/tab open with different items.

    RedirectToUmbracoPage(4515); 

    It works if I were to use the standard MVC redirect to action but only the partial is loaded and not the masterpage/parentview so im missing the outer html etc.  Also you lose the Umbraco data doing this.

    Feel like im really fighting umbraco at the moment with this.  I may build this as a standalone app within the site if nobody has any ideas.

     

     

     

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jan 29, 2014 @ 17:06
    Andy Butland
    100

    I've done this before but using Session, which you say you want to avoid.  I guess if you are saving every step of the way, rather than waiting until the end of the process, you're right to avoid it.  But in my case I only wanted to save at the end so I needed to stash the form submissions from step 1 to be processed on step 2.

    Without Session though, I see your issue.  There is an issue (feature request) I noted for adding overloads to RedirectToUmbracoPage to support querystrings, but nothing at the moment.

    You could do a straight response.redirect I guess (once you have worked out the URL of your step 2 page)?  It's not very MVC, and not really recommended, but it should work OK.

    Andy

  • Damian Green 452 posts 1433 karma points
    Jan 29, 2014 @ 17:52
    Damian Green
    0

    Funnily enough your final example is almost what I have ended up implementing.  I am returning a RedirectResult rather than a Response.Redirect though.

    I am getting the parent node's url and then appending Step1/2/3 etc and ?id=guid on.  This seems a decent workaround for the time being as this has put me behind. Development trials and tribulations for ya hey! :)

    Cheers Andy.

     

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jan 29, 2014 @ 17:56
    Andy Butland
    0

    That's even better - nothing wrong from an MVC perspective there.  For some reason I had in my head that surface controller actions where limitted to a limitted number of ActionResult types (PartialViewResult, ContentResult etc.).  But if RedirectResult is supported that's much better than Response.Redirect.

  • Damian Green 452 posts 1433 karma points
    Jan 29, 2014 @ 18:03
    Damian Green
    0

    Ahh but! hold your horses! :) Just found out first hand why even return Redirect is still crap here.  Any validation errors (and also probably any data passed in a similar way) is lost doing it this way if you dont use CurrentUmbracoPage()

    Be careful. :)

    Looks like im going to have to mix the 2.

     

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jan 29, 2014 @ 18:10
    Andy Butland
    0

    Yes, that's true.  Make sure you check out the documentation here (particularly the example under "Creating the SurfaceController Action").

    The pattern should be that you use CurrentUmbracoPage() if validation fails (to go back to the current view) and RedirectToUmbracoPage (or return RedirectResult) if all is OK, you've processed the data and want to move on to the next step.

     

Please Sign in or register to post replies

Write your reply to:

Draft