Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jun 16, 2014 @ 18:56
    Ismail Mayat
    1

    SurfaceController RedirectToCurrentUmbracoPage with querystring

    Guys,

    Using umbraco 616 and in my surfacecontroller I do return RedirectToCurrentUmbracoPage(); what i also want to do is pass through a querystring well its actually an anchor so something like #review--thanks so when page loads it jumps to that anchor.  How do i do this?  Route hijack?

    Regards

    Ismail

  • Dan Patching 31 posts 158 karma points c-trib
    Jun 16, 2014 @ 19:08
    Dan Patching
    0

    There's probably a better way, but how about ....

    var url = Umbraco.Url(CurrentPage.Id);
    return Redirect(url + "#review--thanks");

    (Untested) :D

  • Charles Afford 1163 posts 1709 karma points
    Jun 16, 2014 @ 20:54
    Charles Afford
    0

    Hi Ismall

    There is a property on the RedirectToCurrentUmbracoPage() i think called URL something like that.  I did something like

    string url = RedirectToCurrentUmbracoPage().Url

    StringBuilder stringBuilder = new StringBuilder();

    stringBuilder.append(url).append("?...")

    Response.Redirect(Url);

    Hope this helps.

    Charlie

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jun 17, 2014 @ 10:08
    Ismail Mayat
    100

    Charles, Dan,

    Issue is this is a partial so it will ysod.  Additionally doing redirect will throw exception under the hood which will be logged in elmah, so after thinking about this a bit more, I will in the view test for a tempdata field i already set then just put some js in there to do the scroll to anchor.

    Regards

    Ismail

  • Charles Afford 1163 posts 1709 karma points
    Jun 18, 2014 @ 00:09
    Charles Afford
    0

    Ismll why yellow screen of death?  and let us know how you get on with that approach :)

    Charlie

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jun 18, 2014 @ 16:02
    Ismail Mayat
    0

    Charles,

    My tempdata hack works nicely.

    Regards

    Ismail

  • Charles Afford 1163 posts 1709 karma points
    Jun 18, 2014 @ 21:50
    Charles Afford
    0

    Great glad you got it working :)

  • Stephen Davidson 216 posts 392 karma points
    Sep 14, 2015 @ 11:48
    Stephen Davidson
    0

    I'm trying to do this very thing...after postback display message and scroll to bottom of the page where the contact form is...could you explain how it was done? Can we not add something to RedirectToCurrentUmbracoPage()?

     try
                {
                    umbraco.library.SendMail(sendEmailsFrom, sendEmailsTo, subject, body, true);
    
                    TempData["InfoMessage"] = "Your message has been successfully sent and we will be in touch soon...";
    
                    // Clear all the form fields
                    ModelState.Clear();
                    model.FullName = string.Empty;
                    model.Company = string.Empty;
                    model.Telephone = string.Empty;
                    model.Email = string.Empty;
                    model.Message = string.Empty;
    
    
                    //redirect to current page to clear the form
                    return RedirectToCurrentUmbracoPage();
                }
                catch (Exception ex)
                {
                    TempData["ErrorMessage"] = "There was an issue sending your message: " + ex.Message + ex.StackTrace;
                }
    
Please Sign in or register to post replies

Write your reply to:

Draft