Copied to clipboard

Flag this post as spam?

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


  • Saied 349 posts 674 karma points
    Sep 21, 2015 @ 19:01
    Saied
    0

    RedirectToCurrentUmbracoPage() removes my query string?

    When I go to the following page:

    http://localhost/Products/Product/23/red-crayon

    There is a Buy Now button which makes a POST and updates a database. The problem is when I call RedirectToCurrentUmbracoPage, it redirects to http://localhost/products/product and complains that it is looking for a ProductViewModel, but I am passing it a RenderModel.

    Product is just a placeholder in my site structure to hold virtual nodes and the part after product /23/red-crayon is part of a custom route. When I do a redirect, I would like to stay on the page with the query string. Is there a way to do it with RedirectToCurrentUmbracoPage (It does seem like this would redirect to /products/product since I am actually on a products page)

    I have tried RedirectToCurrentUmbracoUrl and this does redirect to the current page with the url, but I wasn't sure if this was the correct way?

  • Carl Jackson 139 posts 478 karma points
    Sep 22, 2015 @ 13:22
    Carl Jackson
    0

    RedirectToCurrentUmbracoPage takes a string for queryString which I imagine will get you to where you want to go but maybe just not with the clean URL.

    Alternatively you should be able to return new RedirectResult("/url"); and build the URL yourself?

    Thanks

    Carl

  • Saied 349 posts 674 karma points
    Sep 22, 2015 @ 13:26
    Saied
    0

    Hi,

    So is RedirectToCurrentUmbracoUrl the same as RedirectResult(/url)?

  • Nicolai Christiansen 4 posts 96 karma points
    Nov 28, 2018 @ 10:27
    Nicolai Christiansen
    1

    Some years later..

    try this

    RedirectToCurrentUmbracoPage("?id=" + MyId);

    this will redirect with the desired query string

  • baile185 2 posts 22 karma points
    Aug 19, 2020 @ 17:33
    baile185
    0

    FYI, I tried it without the "?" and it worked fine. Example:

    RedirectToCurrentUmbracoPage("id=" + MyId);

  • 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