Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Names property
Collapse the table of content
Expand the table of content

SPWebCollection.Names property

Gets an array that contains the site-relative URLs of all the websites in the collection.

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

public string[] Names { get; }

Property value

Type: []
A string array that contains the site-relative URLs.

The following code example displays the URL of each site in the current site collection.

This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.

SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;
string[] strNames = collWebsites.Names;
foreach (string strName in strNames)
{
    Response.Write(SPEncode.HtmlEncode(strName) + "<BR>");
}
Show:
© 2015 Microsoft