tags:

views:

42

answers:

3

When I am looking at a Sharepoint site home page, how can I tell if it is a site collection or a site? I also have the admin permissions if that helps, but, as you can see, no administration knowledge. :-)

+3  A: 

A site collection will be at the top level after your sites qualifier (by default, this is "sites").
So http://[server.domain]/sites/First is a site collection,

But http://[server.domain]/sites/First/Second is site within the site collection.

Another way (if you are a site collection administrator) is to go to the site settings for any site. If you see the 4th column on the right labeled "Site Collection Administration" then you are at the top of a site collection. If you see "Go to Top Level Settings" then you are in a subsite.

You can also get a full list of all site collections from the Central Administration -> Application -> Site Collection List

Peter Jacoby
+1  A: 

If you create an instance of an SPSite object by passing an URL into its constructor, the SharePoint API will create a valid object out of that.

Now, if you call OpenWeb() on that object, you will get an instance of the SPWeb object that your given URL refers to.

Then you can compare the SPSite.URL (url of the root web of that site) to SPWeb.Url (url of your web). If they are the same, you have an url of a site collection.

Your code will look something like this (I don't have Visual Studio with me at the moment, so this is just pseudo-code)

string sUrl = "http://someserver/zeiten/mysite1/someweb";
 Using (SPSite oSite = new SPSite(sUrl)){
  Using (SPWeb oWeb = oSite.OpenWeb()){
    if (oWeb.Url == oSite.Url) {
      //sUrl refers to a site collection
     } else{
      //you actually have an url of some sub-web
     }
 }
}

See responses to a similar question of mine: http://stackoverflow.com/questions/1998271/finding-sharepoint-list-item-by-its-display-forms-url

naivists
A: 

Looking only at a homepage, there is no way to distinguish between a site collection and a site. A site collection is basically nothing more than a container with a root site in it (SPSite.RootWeb in code). That root site (or web / SPWeb in sharepoint terms) can have other sub sites (webs) under it.

A web application contains one or more site collections. Site collections can be grouped together using managed paths that are defined in the Central adminstration. a managed path is either explicit or wildcard. explicit means only site collection can be created in that managed path, i.e.

http://rootsitecoll/explicitpath/

where the explcit managed path IS the new site collection's url.

Wildcard means 1 or more site can be created under the managed path, i.e.:

http://rootsitecoll/departments/departmentsite, where departments is a wildcard managed path.

Colin