views:

289

answers:

2

Hi,

I have a very basic question here. I am confused between SPSite. SiteCollection and SPWeb.

So my understanding is (or what I could research on this) that,

http://My_server >>> TOP Level SIte or SPWEbApplication http://My_server/My_site >>>> Site Collection or SPSite

Now a site under SPSite that will be referenced through SPWeb. So what are we getting when using SPWeb.Webs. What is a Subsite?

Please let me know if I need to rephrase the question or more info is needed.

Thanks.

SPWeb mySite = SPContext.Current.Web;
SPWebCollection sites = mySite.Webs;

foreach (SPWeb subSite in sites)
{
    Response.Write(SPEncode.HtmlEncode(subSite.Title) + "<BR>");
}
+6  A: 

The top level site collection (SPSite) is a container in which you have your root web (SPWeb) and subsites (SPWebs under SPWebs) - it takes a while to get used to the names.

Here's a nice diagram from the Microsoft site:

alt text

Therefore, a subsite will be any site (SPWeb) under the top level web site in a site collection (SPSite).

Blakomen
A: 

The top level site is also referred to as the Root Web (SPSite.RootWeb)

Kyle