Copied to clipboard

Flag this post as spam?

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


  • Jason Espin 368 posts 1335 karma points
    Apr 12, 2016 @ 15:59
    Jason Espin
    0

    Best way to display partial view with message following RedirectToCurrentUmbracoPage()

    Hi all,

    I am currently on the final stages of developing a one stage booking process where:

    1. The user enters their information including card details

    2. The details are processed and passed off to a third party payment system using web services

    3. The results of the payment request are returned

    4. Upon failure, I use CurrentUmbracoPage() to allow the user to resubmit and amend some of their details

    5. Upon success, I want to redirect the user away (so they cannot click refresh and pay again) but also display either a new view or alternate template with a confirmation message and receipt.

    It is the sucess bit I am struggling with. I have tried the following:

    RedirectToAction("Confirmation")
    

    which utilises

    public ActionResult Confirmation() {
       return View("Confirmation")
    }
    

    The problem with this is it redirects to a horrible looking url like:

     http://localhost:54293/umbraco/Surface/Booking/Confirmation
    

    instead of the actual page I was on:

    http://localhost:54293/tours/this-tour-is-a-test

    I've also tried using RedirectToCurrentUmbracoPage() passing in a querystring but this again looks messy with the alttemplate querystring in place. Ideally, if I could use the other form of alttemplate where I just append the alternate template name to the end of the url, that would be perfect but I have not yet found a way of doing that.

    Can anyone advise what would be best here? My preference would be to still display the same URL but render a different view that shows the confirmation information with a button that allows the user to go back to the original version of the page.

    Any hints or tips would be greatly appreciated as my base MVC knowledge still isn't too strong.

    Cheers,

    Jason

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Apr 12, 2016 @ 22:53
    Marc Goodson
    0

    Hi Jason

    I think from the scenario you are describing you could just return a redirect result, with your altTemplate name appended; in the format you prefer;

    eg:

      var currentPageUrl = CurrentPage.Url + "/altTemplateAlias";
     return Redirect(currentPageUrl);
    

    The other approach would be to set a flag in the TempData dictionary, which will survive the RedirectToCurrentUmbracoPage() and then in your existing partial check for the existence of the flag and render something different.

    eg.

    TempData["success"] = true;
    Return RedirectToCurrentUmbracoPage();
    

    and then in your partial have a check:

    if (TempData["succcess"] != null){
     // display form submitted message
    }
    else {
    // render the form ready to be filled in
    }
    

    regards

    Marc

  • Jason Espin 368 posts 1335 karma points
    Apr 13, 2016 @ 08:25
    Jason Espin
    0

    Is this the standard convention that is supposed to be used in MVC though? I've used this method before but I'm sure there is something that is more robust out there. I can't believe that you cannot just render an alternative view on the same page to display different content but that thanks for the response.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies