Create Site Collection Programatically from Top level Site Collections

Hi,

How to create different Site Collection Programmatically as a Visual Web Part in Top Level Site Collection in same web Application.

September 13th, 2015 6:27am

Ravi,

You can run PowerShell script for creating site collection in webpart.

I haven't tried myself but below link can help you to 

Take a look at http://www.codeproject.com/KB/cs/HowToRunPowerShell.aspx. This is the type of code you'll need to write/consider.

Free Windows Admin Tool Kit Click here and download it now
September 13th, 2015 7:19am

Hi,

According to your description, my understanding is that you want to create different site collection in the same web application using web part in top level site collection.

I suggest you can create a custom web part and with the code snippet like below to create site collection for the specific web application:

string SiteCollectionUrl = "/sites/test3";

            Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(() =>
            {
                var Application = SPWebApplication.Lookup(new Uri("http://sp2013sps/"));
                Application.Sites.Add(SiteCollectionUrl, "TeamSite Created By C#", string.Empty, 1033, "STS#0", "contoso\\Administrator", "contoso\\Administrator", String.Empty);
            });

Thanks

Best Regards

September 14th, 2015 2:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics