SPUtility.Redirect Method (String, SPRedirectFlags, HttpContext) (Microsoft.SharePoint.Utilities)

Namespace: Microsoft.SharePoint.Utilities
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
Public Shared Function Redirect ( _
    url As String, _
    flags As SPRedirectFlags, _
    context As HttpContext _
) As Boolean
Visual Basic (Usage)
Dim url As String
Dim flags As SPRedirectFlags
Dim context As HttpContext
Dim returnValue As Boolean

returnValue = SPUtility.Redirect(url, flags, context)
C#
public static bool Redirect (
    string url,
    SPRedirectFlags flags,
    HttpContext context
)

Parameters

url

flags

context

See Also

Tags :


Community Content

kaneboy
Who can explain the "flags" parameter?
Who can explain the "flags" parameter? I checked document of "SPRedirectFlags" type, but have no idea about it.

Cimares
Good article on this by Ton Stegeman
Ton Stegeman has written a very good article on using the SPRedirectFlags at http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?ID=102

Ketaanh Shah
From Ton Stegeman's blog, putting it here
Thanks a lot to Ton Stegeman for explaining the Flags: PLEASE READ HIS BLOG FOR MORE DETAILS: http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?ID=102

Source url

If UseSource is part of the flags parameter of the Redirect method, the url to which the user is redirected will be read from the querystring of the original request (context parameter). The new url will be the value of one of these querystring parameters:

  • Source
  • NextUsing
  • NextPage

If one of these parameters has a value, the new url will be validated. Validation is done by the IsUrlSafeForRedirect method of the Request property of the current SPWeb. The url in the querystring of the original request needs to be a relative url. See the samples below.

If this url is not valid, or the UseSource parameter resulted in an empty string, the url parameter that was originally passed will be used.

Static url

If Static is part of the flags parameter, the url is considered relative. Depending on the presence of RelativeToLayoutsPage in the flags parameter, the url is relative to the ´_layouts´. If this enumeration value is present, SharePoint checks the flags parameter for the presence of RelativeToLocalizedLayoutsPage. If this is present, a new absolute url to the localized ‘_layouts’ folder is constructed. If not, the url is constructed to the root of the ‘_layouts’ folder. The layouts url is the url of the current SPWeb, followed by ‘_layouts’ and the Language of the current SPWeb. If constructing this url fails for whatever reason, the url will be the url of the current SPSite. If required, the value of SPGlobal.ServerCulture.LCID is added to the url.

Absolute url

If Static is NOT part of the flags parameter, the user will be redirected to the value of the url parameter, after validating the url. If Trusted is part of the flags parameter, the url is always valid. If Trusted is not available, it depends on the outcome of the IsUrlSafeForRedirect method of the Request property of the current SPWeb whether or not the url is valid.

Encoding

The last step is before the user is redirected is the encoding. If DoNotEncodeUrl is NOT present in the flags attribute, the url is first encoded using SPHttpUtility.UrlPathEncode.

Tags :

Page view tracker