SPUtility.Redirect

13 Feb

Use the Redirect method of the SPUtility class when performing redirects on SharePoint. Take a look at the code below.

SPUtility.Redirect(“/MyFolder/MyPage.aspx”, SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current);

On SharePoint 2010 it will redirect to http://yoursite/_layouts/MyFolder/MyPage.aspx while on SharePoint 2013 it will redirect to http://yoursite/_layouts/15/MyFolder/MyPage.aspx. You see that in SharePoint 2013 the URL it contains the HIVE folder while in 2010 it doesn’t. Using the Redirect method with the RelativeToLayoutsPage option you don’t have to worry about that.

For a complete reference visit MSDN – SPUtility.Redirect

Happy coding and cheers!

One Response to “SPUtility.Redirect”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: