Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SharePoint Online (Office 365) create site problem

$
0
0

Hi, I ran into a problem when programmatically creating a new site in SharePoint Online. I try to run it from a webpart. On-premise everything is working like a charm, but when i deploy it to SharePoint Online it "Sometimes" generates an error. I get the folowing exception:

Microsoft.SharePoint.SPException: The Web site address "/nederlands/blablablablalblasd" is already in use. ---> System.Runtime.InteropServices.COMException: 0x800700b7The Web site address "/nederlands/blablablablalblasd" is already in use. at ..............

The webpart has to create a site and create a group for the site. Group members are populated from listitems. The code i use is:

            using (SPSite currentSite = SPContext.Current.Site)
            {
                using (SPWeb currentWeb = currentSite.OpenWeb())
                {
                    try
                    {
                        SPWeb site = null;
                        uint lcid = currentWeb.Language;
                        string templateName = "WIKI#0";
                        site = currentWeb.Webs.Add(siteName.Text, siteName.Text, siteDesc.Text, lcid, templateName, true, false);
                    }
                    catch (Exception exception)
                    {
                        DebugUsingLiteral(exception.ToString());
                    }
                }
            }

It is not always generating an error. If i change the site name in my textbox after i get an error and retry, it works well. Hope you can help me out.



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>