[英]SharePoint 2013 Online (Office 365) create site error
I ran into a problem when programmatically creating a new site in SharePoint Online. 在SharePoint Online中以编程方式创建新网站时遇到了一个问题。 I try to run it from a webpart. 我尝试从Webpart运行它。 On-premise everything is working like a charm, but when I deploy it to SharePoint Online it generates an error occasionally. 在内部部署中,所有事物都像魅力一样运转,但是当我将其部署到SharePoint Online时,有时会产生错误。 If I change the site name in my textbox after I get an error and retry, it works well. 如果在收到错误并重试后在文本框中更改了站点名称,则它可以正常工作。
I get the following exception: 我得到以下异常:
Microsoft.SharePoint.SPException: The Web site address "/nederlands/blablablablalblasd" is already in use. Microsoft.SharePoint.SPException:网站地址“ / nederlands / blablablablalblasd”已在使用中。 ---> System.Runtime.InteropServices.COMException: 0x800700b7The Web site address "/nederlands/blablablablalblasd" is already in use. ---> System.Runtime.InteropServices.COMException:0x800700b7该网站地址“ / nederlands / blablablablalblasd”已在使用中。 at .............. 在 ..............
The webpart has to create a site and create a group for the site. Webpart必须创建一个网站并为该网站创建一个组。 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());
}
}
}
Hope you can help me out. 希望你能帮助我。
Ended up by switching from a webpart to an App. 最后从Webpart切换到App。 In my opinion SharePoint 2013 Online and CSOM is a much better combination. 在我看来,SharePoint 2013 Online和CSOM是更好的组合。
It also gives yout the ability to debug your solutions in the SPOnline environment. 它还使您能够在SPOnline环境中调试解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.