Webs.WebUrlFromPageUrl Method (Webs)
Webs.WebUrlFromPageUrl Method (Webs)
Returns the URL of the parent site for the specified page URL.

Web Service: WebsWeb Reference: http://<Site>/_vti_bin/Webs.asmx
Syntax

'Usage

Dim instance As Webs
Dim pageUrl As String
Dim returnValue As String

returnValue = instance.WebUrlFromPageUrl(pageUrl)

'Declaration

<SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/WebUrlFromPageUrl", RequestNamespace:="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace:="http://schemas.microsoft.com/sharepoint/soap/", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Function WebUrlFromPageUrl ( _
    pageUrl As String _
) As String

Parameters

pageUrl

A string that contains the absolute URL of the page.

Return Value

A string that contains the site URL.
Remarks

If the page URL is "http://Server_Name/Web_One/Web_Two/Web_Three/Lists/Events/Allitems.aspx", the WebUrlFromPageUrl method returns "http://Server_Name/Web_One/Web_Two/Web_Three". If the Web site does not exist on the server, the top-level site is returned.

Example

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)
See Also

© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View