Compartilhar via


SiteData.GetSiteAndWeb Method

Returns the absolute URL of a subsite and the absolute URL of its top-level parent site based on the specified site URL.

Namespace:  [SiteData Web service]
Web service reference: http://Site/_vti_bin/SiteData.asmx

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/GetSiteAndWeb", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function GetSiteAndWeb ( _
    strUrl As String, _
    <OutAttribute> ByRef strSite As String, _
    <OutAttribute> ByRef strWeb As String _
) As UInteger
'Usage
Dim instance As SiteData
Dim strUrl As String
Dim strSite As String
Dim strWeb As String
Dim returnValue As UInteger

returnValue = instance.GetSiteAndWeb(strUrl, _
    strSite, strWeb)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/GetSiteAndWeb", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public uint GetSiteAndWeb(
    string strUrl,
    out string strSite,
    out string strWeb
)

Parameters

  • strUrl
    Type: System.String

    The absolute URL of the parent top-level site.

Return Value

Type: System.UInt32
A 32-bit unsigned integer that returns 0 to indicate that the operation has completed.

Examples

The following code example displays the absolute URLs of a top-level site and a subsite. This example assumes the existence of a label within the form of a Windows Application.

Dim srvSiteData As New Web_Reference_Name.SiteData()
srvSiteData.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim siteCollection As String
Dim site As String

srvSiteData.GetSiteAndWeb("http://Server_Name/sites/Site/Subsite", siteCollection, site)

label1.Text = siteCollection + " :: " + site
Web_Reference_Name.SiteData srvSiteData = new Web_Reference_Name.SiteData();
srvSiteData.Credentials = System.Net.CredentialCache.DefaultCredentials;

string siteCollection;
string site;

srvSiteData.GetSiteAndWeb("http://Server_Name/sites/Site/Subsite", 
    out siteCollection, out site); 

label1.Text = siteCollection + " :: " + site;

See Also

Reference

SiteData Class

SiteData Members

SiteData Web Service