Copied to clipboard

Flag this post as spam?

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


  • Jay Crowe 42 posts 173 karma points
    Jun 08, 2023 @ 14:54
    Jay Crowe
    0

    View Component submit Form not performing a redirect

    Hi,

    I have a view component which has a simple form on it to sign people up to my marketing emails. This form is wrapped with the Begin Umbraco Form which posts the email to a surface controller. Within the surface controller method it saves the email address and then returns a Redirect to Umbraco Page.

    I can see in the network tab that the thank you page is being called but for some reason the page is not displaying and I am just remaining on the page I submitted the email from.

    Please could somebody help?

    Regards, Jay

  • Jay Crowe 42 posts 173 karma points
    Jun 08, 2023 @ 14:56
    Jay Crowe
    0

    I have also tried just returning CurrentUmbracoPage and Setting a ViewData object and wrapping the form so that if it is set to true show a thank you message but that didnt work either

  • Huw Reddick 1746 posts 6110 karma points MVP c-trib
    Jun 09, 2023 @ 07:56
    Huw Reddick
    0

    IIRC I set a TempData[""] variable and do a return RedirectToCurrentUmbracoPage()

  • Jay Crowe 42 posts 173 karma points
    Jun 09, 2023 @ 12:19
    Jay Crowe
    0

    That did not work sorry. I can see the call and redirect in the network tab of developer tools, but it is as if the view component is preventing it from redirecting?

  • Jay Crowe 42 posts 173 karma points
    Jun 09, 2023 @ 13:55
    Jay Crowe
    0

    I managed to work out the issue. The way I was building up the razor for the UmbracoBeginForm was causing an issue and creating the post as an xhr type. So it was working but then it wasn't actually creating a redirect.

    I have now fixed the razor and the form now posts and redirects me to an umbraco page as intended.

    Thanks for you help.

Please Sign in or register to post replies

Write your reply to:

Draft