2
votes

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.

2
Check your web application web.config file. By default for web application on 80 port it is located in C:\inetpub\wwwroot\wss\VirtualDirectories\80 folder. What is the value of system.web/httpRuntime tag's executionTimeout attribute?Yevgeniy.Chernobrivets
That attribute is currently not set explicitly in the web.config. Normally I would expect that SPLongOperation overrides the web.config timeout setting.Jeroen van Lieshout
I'm not sure that it works like you said. But you were right in some way that this page overrides this setting - check web.config in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS folder. It has executionTimeout set to 360 seconds (6 minutes). Try to increase it. Also do not forget that you need to do iisreset after changing web.config file.Yevgeniy.Chernobrivets
Messed up pass a little bit - correct one for SharePoint 2013 is C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTSYevgeniy.Chernobrivets
When I change the executionTimeout attribute in the web.config in the 15 hive, then the timeout occurs according to the time set. So it seems that the mechanism to override that timeout is not working on my machine. I'm not allowed to change web.config settings in the environment where I want to deploy the solution so I need a proper solution for this.Jeroen van Lieshout

2 Answers

2
votes

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

0
votes

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.