I have a controller action for a form submission (see code below). When I submit the form, the controller action gets hit immediately and the code runs quite quickly. However, after it returns, the page just hangs for anywhere from 10-30s and even worse
on shared hosting.
I'm redirecting to the same page as the form. This page loads very quickly (<1s) on a GET.
I put a breakpoint in the debugger on the controller action, then on the view which loads. I can see the delay here between when the controller returns the redirect and when the view gets hit.
Does anyone know why this redirect could be taking so long to return?
public ActionResult CreatePOST(string returnUrl)
var referPatientSubmission = _contentManager.New("ReferPatientSubmission");
var referPatientSubmissionPart = referPatientSubmission.As<ReferPatientSubmissionPart>();
dynamic model = _contentManager.UpdateEditor(referPatientSubmission, this);
referPatientSubmissionPart.DateCreated = DateTime.Now;
foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage))
TempData["ShowConfirmationMessage"] = true;
TempData["ReferPatientNumber"] = referPatientSubmission.Id;
_vitalCallServices.Subscribe(referPatientSubmissionPart.ReferrerFirstName + " " + referPatientSubmissionPart.ReferrerSurname, referPatientSubmissionPart.ReferrerEmail, "Referrer");
return this.RedirectLocal(returnUrl, "~/");