Share via


SPWeb.GetServerRelativeUrlFromUrl method

Given a full, server relative or web relative url, returns a server relative url that always starts with a slash.

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

Syntax

'Declaration
Public Function GetServerRelativeUrlFromUrl ( _
    fullOrRelativeUrl As String _
) As String
'Usage
Dim instance As SPWeb
Dim fullOrRelativeUrl As String
Dim returnValue As String

returnValue = instance.GetServerRelativeUrlFromUrl(fullOrRelativeUrl)
public string GetServerRelativeUrlFromUrl(
    string fullOrRelativeUrl
)

Parameters

  • fullOrRelativeUrl
    Type: System.String

    Canonicalized full, server relative, or web relative url. To canonicalize the url it should be passed to Utility.CanonicalizeFullOrRelativeUrl(). Incoming url can be 1. - web relative i.e. it doesnt start with a / 2. - server relative i.e. it starts with a / 3. - full url i.e. it starts with http or https

Return value

Type: System.String
Canonicalized server relative url that may or may not be valid.

See also

Reference

SPWeb class

SPWeb members

Microsoft.SharePoint namespace