SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been given a task to create an event that dynamically creates new site collections on our sharepoint webApp. Thing is using Central Admin I can create "" and it is a top level site.

However SharePoint does not seem to allow new top level sites created from code?

 private void createSite(String newUrl, SPSite Sender, SPUser current)
      SPWebApplication webApp = Sender.WebApplication;
      SPSite mysite = webApp.Sites.Add(newUrl, "Title", "Desc", 1033, null, current.LoginName, current.Name, current.Email))


So. CA -> add "" = top level site

But c# ->add "" = sub site

Where do I go wrong?

share|improve this question
up vote 2 down vote accepted

Normally when you do this, you need to make use of the Managed Paths and create the new site collections under that. In most cases, this is /sites/ but can be changed to whatever suits your needs.

In your example, you would have the root site collection under /newSite1 and then all subsequent site collections would be under /sites/newsite2, /sites/newsite3, and so on.

This approach also makes it very clear where the boundary is for site collections for the purposes of management and administration.

share|improve this answer
I had been using /site/ not /sites/ in my real code. Thank you – user13186 Apr 2 '13 at 17:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.