I came across a scenario where I need to redirect to a external url(thank you page) after form submission. It’s achievable using formSubmitContext’s RedirectUrl property on your Custom Submit Action.
Here is the code snippet –
protected override bool Execute(string data, FormSubmitContext formSubmitContext) { //Prepare model //WebApi Call //Redirect to external URL var thankYouPageUrl = $"{HttpContext.Current.Request.Url?.Scheme}://{HttpContext.Current.Request.Url?.Host}/[thank-you-page-path]/"; formSubmitContext.RedirectUrl = $"{thankYouPageUrl}?id={add-any-querystring-if-needed}"; formSubmitContext.RedirectOnSuccess = true; return true; }
Hope this helps someone. Happy Sitecoring!