Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.");
            }

        }
    }
share|improve this question
    
Did you debug it to see where it is actually hanging - the code looks fine. –  Max Melcher Sep 10 '12 at 10:07
add comment

1 Answer

Did you tried this code in Internet Explorer ? as there are problems redirecting through code for chrome and firefox and you can fix them somehow thought.

hope it helps :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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