Redirect method (String, SPRedirectFlags, HttpContext, String)
Collapse the table of content
Expand the table of content

SPUtility.Redirect method (String, SPRedirectFlags, HttpContext, String)

Handles the redirection of an HTTP request. This method allows for the optional specification of an encoded query string to be added to the URL.

Namespace:  Microsoft.SharePoint.Utilities
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public static bool Redirect(
	string url,
	SPRedirectFlags flags,
	HttpContext context,
	string queryString


Type: System.String

The destination URL to be used in the redirection.

Type: Microsoft.SharePoint.Utilities.SPRedirectFlags

A valid combination of flags from the SPRedirectFlags enumeration that indicate how the redirection should be made.

Type: System.Web.HttpContext

The HTTPContext object that provides HTTP information about the current HTTP request.

Type: System.String

An encoded query string to be appended to the selected URL. This parameter is optional.

Return value

Type: System.Boolean
true if the redirection was made; otherwise, false.

If the SPRedirectFlags.UseSource flag is set, this method redirects to the source query string, if it is available. If this flag is not set or if the source query string is not available, this method redirects to the URL specified in the url parameter.

This method performs validation of the URL depending on the flags set in the SPRedirectFlags enumeration. Set the SPRedirectFlags.Trusted flag to ensure that the URL is valid without checking whether the URL destination is located on a local server. To perform the redirection without validation, set the SPRedirectFlags.Static flag.

© 2016 Microsoft