Jeroen van Lieshout
Jeroen van Lieshout

Reputation: 23

SharePoint 2013: SPLongOperation timing out

Currently I'm experiencing an issue with SPLongOperation in SharePoint 2013. I have some custom logic which takes at least 15 minutes to process and therefore I use a SPLongOperation to make sure it's not timing out after 6 minutes. In the past this piece of code worked on SharePoint 2010. The problems is that the code execution stops exactly after 6 minutes. With debugger attached it doesn't timeout, so somehow the SPLongOperation block is ignored or not working correctly. The code I use to call the SPLongOperation is as follows:

using (SPLongOperation operation = new SPLongOperation(Page))
{
    try
    { 
        operation.LeadingHTML = html; //adding some custom html...
        operation.Begin();

        // Business Logic
    }
    finally
    {
        operation.End("/page.aspx", SPRedirectFlags.RelativeToLayoutsPage, Context, string.Empty);
    }
}

The behavior I see at several machines with this piece of code is that after 6 minutes a Timeout occurs with the following exception in ULS: System.Web.HttpException: Request timed out. Has anyone an idea what might be the problem? I'm using SharePoint 2013 with October CU installed on it. I also tested this block using a while(true) statement to make sure the business logic is not causing the problem.

Upvotes: 2

Views: 4748

Answers (2)

Tomas
Tomas

Reputation: 36

Also have this problem, found this approach, define the timeout for the page, before creation SPLongOp object:

Page.Server.ScriptTimeout = 3600; // specify the timeout to 3600 seconds
 using (SPLongOperation operation = new SPLongOperation ( this .page))
 {
 }

Source: http://shaharpan.wordpress.com/2014/11/20/splongoperation-thread-was-being-aborted-error-in-sharepoint-2013/

Tomas

Upvotes: 2

Burst
Burst

Reputation: 709

SPLongOperation keeps a connection between client and server open while executing. Its purpose is to inform a user that everything is OK, but it takes a little time (2-3 minutes) to finish whatever is to be finished.

So if you need to run a really long procedure (e.g., lasting for 1 hour) you need to use other ways, timer jobs, for instance.

Upvotes: 0

Related Questions