Tuesday, August 14, 2007

Syntax for SPLongOperation.End(string sRedirectUrl)

A while ago I wrote about Compiling SharePoint 2007 audiences using the SharePoint object model (C# code sample) which was used in a custom SharePoint application page.  Since the code in this custom application page might take a while to run I used the SPLongOperation class to show the nice SharePoint 2007 "Operation in progress" user interface while the code is running.

When your code is finished you can redirect to a specific web page by using SPLongOperation.End() method and passing in a url - the code below redirects to the previous page which called into the SharePoint application page.

operation.End(Request.ServerVariables["http_referer"].ToString());

Now, something which I forget was that the URL string that you pass in should not be URLEncoded so the syntax should be

operation.End(SPEncode.UrlDecodeAsUrl(Request.ServerVariables["http_referer"].ToString())); 

 


No comments:

Post a Comment