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”