I got the following code below , it starts a long running process , once the processing completes it will redirects to another page using EndScript().However,SPLongProcess never redirects to the destination page and hanging on the processing page forever.But the actual processing is complete.All the data is saved , web service is called , error is handled. Can someone shine some light on this?
private void HandleSubmitClicked()
{
SPWeb web = SPContext.Current.Web;
SPListItem currentItem = SPContext.Current.ListItem;
var applicationRepository = new ApplicationRepository(web, new DocumentSetGenerator(web));
var application = ApplicationBuilder.Build(currentItem);
using (SPLongOperation longOperation = new SPLongOperation(Page))
{
longOperation.LeadingHTML = "Submitting to Orca";
longOperation.TrailingHTML = "Please wait while the application is being processed.";
longOperation.Begin();
try
{
string newLocation = new SubmitToOrcaController(new ApplicationProcessorFactory(web).ApplicationProcessor(), applicationRepository).Submit(application);
string libraryLocation = string.Format("{0}/{1}", web.Url, ApplicationLibraryNamesConstant.ApplicationLibraryName);
string endScript = string.Format("window.location = \"{0}\";", newLocation);
if (newLocation.Equals(libraryLocation, StringComparison.InvariantCultureIgnoreCase))
{
endScript = string.Format("window.location = \"{0}?queuename={1}\";", newLocation,application.Queue);
}
longOperation.EndScript(endScript);
}
catch (ThreadAbortException)
{
//The explanation for how the exception is handled is from the blog post below.
//http://peterheibrink.wordpress.com/2009/09/07/splongoperation/
// Don’t do anything, this error can occur because the SPLongOperation.End
// performs a Response.Redirect internally and doesnt take into account
// that other code might still be executed
}
catch (Exception)
{
// When an exception occurs, the page is redirected to the error page.
// Redirection to another (custom) page is also possible
SPUtility.TransferToErrorPage("There is a problem to process your application.");
}
}
}