Webs.WebUrlFromPageUrl Method
Returns the URL of the parent site for the specified page URL.
Namespace: [Webs Web service]
Web service reference: http://Site/_vti_bin/Webs.asmx
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/WebUrlFromPageUrl", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function WebUrlFromPageUrl ( _
pageUrl As String _
) As String
'Usage
Dim instance As Webs
Dim pageUrl As String
Dim returnValue As String
returnValue = instance.WebUrlFromPageUrl(pageUrl)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/WebUrlFromPageUrl", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/",
ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string WebUrlFromPageUrl(
string pageUrl
)
Parameters
pageUrl
Type: System.StringA string that contains the absolute URL of the page.
Return Value
Type: System.String
A string that contains the site URL.
Remarks
If the page URL is "https://Server_Name/Web_One/Web_Two/Web_Three/Lists/Events/Allitems.aspx", the WebUrlFromPageUrl method returns "https://Server_Name/Web_One/Web_Two/Web_Three". If the Web site does not exist on the server, the top-level site is returned.
Examples
The following code example displays the site URL for a specified page URL.
Dim webService As New Web_Reference_Folder_Name.Webs()
webService.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim strPageUrl As String = "http://Server_Name/sites/Site_Name/Lists/Events/AllItems.aspx"
Dim strSiteUrl As String = webService.WebUrlFromPageUrl(strPageUrl)
MessageBox.Show(strSiteUrl)
Web_Reference_Folder_Name.Webs webService = new Web_Reference_Folder_Name.Webs();
webService.Credentials= System.Net.CredentialCache.DefaultCredentials;
string strPageUrl = "http://Server_Name/sites/Site_Name/Lists/Events/AllItems.aspx";
string strSiteUrl = webService.WebUrlFromPageUrl(strPageUrl);
MessageBox.Show(strSiteUrl);