Create site collection programmatically SharePoint 2013

Create site collection programmatically SharePoint 2013

In this post, i describe you to Create site collection programmatically. It is a very rare scenario that we need to provisioning site collections programmatically. When we need to Create a site collection in Bulk, then we need to Create site collection programmatically. It saves time.[AdSense-A]

The code is below that is 100% working:-

 private static void createNewSiteCollection(string RootSiteUrl, string SitecollectionName, string SiteTitle, string Sitedescription, string OwnerloginName, string OwnerName, string OwnerEmail, string WebSitetemplate)
        {

            SPSite rootSite = null;
            try
            {
                using (rootSite = new SPSite(RootSiteUrl))
                {
                    SPWebApplication webApplication = rootSite.WebApplication;
                    using (SPSite newSpCollection = webApplication.Sites.Add(
                      "sites/" + SitecollectionName,  // site URL
                      SiteTitle, // Site Title
                     Sitedescription, // site Descriptions
                      1033, // LCID
                     WebSitetemplate, // web site template
                     OwnerloginName, // owner Login
                     OwnerName, // owner Name
                     OwnerEmail)) // owner Email
                    {


                        string ex = "Create Site Collection" + "  " + "" + newSpCollection.Url + "";
                        ReadWriteException.LogFileWrite(ex);

                    }
                }
            }
            catch (SPException ex)
            {
                ReadWriteException.LogFileWrite(ex.Message);
                ReadWriteException.LogFileWrite(ex.InnerException.Message);
            }
            finally
            {
                rootSite.Dispose();
            }

        }
        public static bool SPSiteReallyExists(string url)
        {
            Uri url1 = new Uri(url);
            return SPSite.Exists(url1);
        }

 


Comments

  1. Usually I do not read post on blogs, but I wish to say
    that this write-up very pressured me to try and do
    it! Your writing style has been amazed me. Thank you,
    very nice post.

  2. Attractive part of content. I just stumbled upon your weblog and in accession capital to claim that I
    acquire in fact loved account your weblog posts.
    Any way I will be subscribing in your feeds and even I achievement you
    get admission to constantly rapidly.

  3. Pingback: Google

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!