1

I Have Created custom submit action in sitecore 9 forms.

In that custom action, I want to reload a same the page with adding of query parameters.

So far I tried.

 Log.Error(Error, typeof(SendDataToApi));
 Log.Error(ErrorDescription, typeof(SendDataToApi));
 //Redirect to a Error Page
 var defaultUrlOptions = LinkManager.GetDefaultUrlOptions();
 defaultUrlOptions.SiteResolving = Settings.Rendering.SiteResolving;
 formSubmitContext.RedirectUrl = new UrlString(LinkManager.GetItemUrl(Sitecore.Context.Item, defaultUrlOptions)) + "?apierror=true";
 formSubmitContext.RedirectOnSuccess = true;
 formSubmitContext.Abort();

It Reloads the page but the querystring was not added ?

Any Help..

1 Answer 1

0

Property that you tries to use is considered to be used for Success form submit

formSubmitContext.RedirectUrl = new UrlString(LinkManager.GetItemUrl(Sitecore.Context.Item, defaultUrlOptions)) + "?apierror=true";
formSubmitContext.RedirectOnSuccess = true;

but, you abort context. It means that forms fails.

formSubmitContext.Abort();

You can try to use standard ASP.Net approach for redirect:

HttpContext.Current.Session.Abandon();
Response.Redirect(new UrlString(LinkManager.GetItemUrl(Sitecore.Context.Item, defaultUrlOptions)) + "?apierror=true", false);
2
  • But I need to redirect in method not in a Action Result.(Response.Redrect is available in Action Result)
    – Rajasekar
    Commented Jun 24, 2019 at 9:53
  • @Rajasekar what is stopping you from calling an ActionResult method from a non ActionResult method? Commented Nov 21, 2019 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.