Forms of URL Strings

Forms of URL Strings

Microsoft Windows SharePoint Services uses different forms of URL depending on the context and member being used. Certain members require an absolute URL, such as the SPSite constructor, or methods in the Microsoft.SharePoint.Administration namespace that require a uniform resource identifier (URI) for a parameter. Most members in the object model instead require a relative URL that is based on the address of the server, such as the Add methods of the SPSiteCollection class. However, some members in the object model require or accept a relative URL that is based on the current site, such as the Add methods of the SPWebCollection class or the OpenWeb method of the SPSite class.

Windows SharePoint Services parses URL strings to determine the form of URL based on a specified protocol (for example, http:) or on the placement of a forward slash (/) within the string. You can use the following forms of URLs:

  • Absolute URL that specifies a full path and that begins by specifying a protocol. For example, http://Server_Name/[sites/]Site_Name/Folder_Name/File_Name.
  • Server-relative URL based on the server address that begins with a forward slash, specifying a complete path from site name to file name. For example, /[sites/]Site_Name/Folder_Name/File_Name.
  • Site-relative URL based on the site address that does not begin with a forward slash and that specifies a complete path from folder name to file name. For example, Folder_Name/File_Name.
  • Relative URL based on the folder containing a file that does not contain any forward slashes and that specifies the name of the file. For example, File_Name.