Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Really hope someone can help.
I have a website which has a contact form on every page which is hidden and shown with some jQuery.
Posting the form and sending the email to the site email address is fine, but the trouble is coming as I want to redirect to a thank you page.
I tried redirecting from the controller which handles the form submission and now I have created a ThankYouController which inherits SurfaceController
I have tried various approaches to this, RedirectToAction, Redirect and not getting the result I want in any case.
Depending on the approach I get issues with this.Umbraco.AssignedContentItem as it's not handled by Umbraco, or as is the case at the moment, the page I've redirected to seems to be being rendered as a partial view.
Does anyone know the correct way to do this?
Something as simple as...
but if I use Redirect("some url"); then I get redirected correctly but the page is being rendered like a partial, so at the top section where the form would be.
If I use return View("view name"); then I get the page but lose the AssignedContentItem stuff which I need.
The easiest thing would be to redirect to the current page return CurrentUmbracoPage(); but we need to redirect to a thank you page.
There must be a nice way people are doing this - anything I'm trying, even though it's not working, feels quite 'hacky'
I'd so something like this to get the thank you page,
// Might be a bit tricky if you have more than one root node
IPublishedContent root = Umbraco.TypedContentAtRoot().FirstOrDefault();
// And assuming you only have one thank you page
IPublishedContent thankYou = root.DescendantsOrSelf("ContactThankYou").FirstOrDefault();
if (thankYou != null)
After the redirect that should be a normal page loading through Umbraco, if you're getting a partial view, check you don't have
Layout = null;
in the view.
Thanks to those who made suggestions.
Looks like TempData["emailSuccess"] = emailSuccess;
return Redirect("~/thank-you"); was working all along but some jQuery issues were rending the result in the header.
TempData["emailSuccess"] = emailSuccess;
I could have saved myself a couple of hours on this!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted