SPWeb.Webs,站点与子站点

SPWeb.Webs,站点与子站点

问题描述:

我对 SPSiteSiteCollectionSPWeb 感到困惑?

I am confused between SPSite, SiteCollection, and SPWeb?

所以我的理解是这个伪代码:

So my understanding is this pseudo code:

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

现在 SPSite 下的站点将通过 SPWeb 引用.那么使用 SPWeb.Webs 时我们得到了什么?

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

什么是子网站?

测试代码:

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

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

*网站集 SPSite 是一个容器,您可以在其中拥有根网站 SPWeb 和子网站SPWebsSPWebs 下 - 需要一段时间才能习惯这些名称.

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 referenced from Microsoft:

因此,子网站将是网站集中*网站SPSite下的任何网站SPWeb.