1

Closed

Slow form submission with RedirectLocal result

description

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?

Thanks!

Image
[HttpPost, ActionName("Create")]
[FormValueRequired("submit.Save")]
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;

    _services.ContentManager.Create(referPatientSubmission, VersionOptions.Draft);

    if (!ModelState.IsValid)
    {
        _transactionManager.Cancel();
        foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage))
        {
            _services.Notifier.Add(NotifyType.Error, T(error));
        }
    }
    else
    {
        _services.ContentManager.Publish(referPatientSubmission);

        TempData["ShowConfirmationMessage"] = true;
        TempData["ReferPatientNumber"] = referPatientSubmission.Id;

        if (referPatientSubmissionPart.IsSignedUpNewsletter)
        {
            _vitalCallServices.Subscribe(referPatientSubmissionPart.ReferrerFirstName + " " + referPatientSubmissionPart.ReferrerSurname, referPatientSubmissionPart.ReferrerEmail, "Referrer");
        }
    }

    return this.RedirectLocal(returnUrl, "~/");
}
Closed Jul 26, 2013 at 10:21 AM by Piedone
As requested.

comments

woodvorg wrote Jul 26, 2013 at 1:01 AM

Sorry... I meant to post this on the forum, not as an issue!! Please close