SPLongOperation in SharePoint 2013

Hi Fellow Readers,

Today, we are going to see one of the important feature in SharePoint 2013 –  SPLongOperation. It is basically used by programmers  to increase the time out of the SharePoint Pages. One interesting fact is that SharePoint Pages in the layouts folder are getting timed out in 6 minutes – 360 seconds.

In order to improve the time out for the long operation such as Site Creation, Site Deletion, Site provision we can add the SPLongOperation class to show some kind of notification to the users saying that something is happening, Kindly please wait while we are processing. Its kind of notification page while the users are waiting for large I/O Operations.

Here is the code to implement SPLongOperation in SharePoint 2013 environment.

//Increase the Time to 6600 seconds

Page.Server.ScriptTimeout = 6600;

using (SPLongOperation mylongOperation = new SPLongOperation(this.Page))
{
// Messages to be shown at the top of the page

mylongOperation.LeadingHTML = “Creating bulk of Sites”;

//Messages to be shown at the bottom of the page

mylongOperation.TrailingHTML = “Please be patient while the sites are being created.”;

longOperation.Begin();

//Write the logic for creating the site creation below

//End the long operation
string redirecttoURL = SPContext.Current.Web.Url + “/SitePages/CustomSiteCreationPage.aspx”;
mylongOperation.End(redirecttoURL);
}

Do visit my blog on the below topics as well

Clear your SharePoint Designer Cache 2010 & 2013

Get the Running Workflows in SharePoint 2013

Stop Workflow in SharePoint 2013 using PowerShell

SP Modal Dialog box in SharePoint 2013

Happy SharePoint Folks 🙂

Please feel free to add any questions around the Sp LongOperation , I’m more than happy to assist.

Leave a Reply

Your email address will not be published. Required fields are marked *