我的项目中有一个事件接收器,在事件接收器中我有以下代码。它被绑定到自定义列表。
public override void ItemAdding(SPItemEventProperties properties) { base.ItemAdding(属性);
//获取引发事件的网站
SPWeb spCurrentSite = properties.OpenWeb();
//Get the name of the list where the event was raised
String curListName = properties.ListTitle;
//If the list is our list named SubSites the create a new subsite directly below the current site
if (curListName == "Customers")
{
//Get the SPListItem object that raised the event
SPListItem curItem = properties.ListItem;
//Get the Title field from this item. This will be the name of our new subsite
String curItemSiteName = properties.AfterProperties["Title"].ToString();
//Get the Description field from this item. This will be the description for our new subsite
string curItemDescription = properties.AfterProperties["Description"].ToString();
//Update the SiteUrl field of the item, this is the URL of our new subsite
properties.AfterProperties["SiteUrl"] = spCurrentSite.Url + "/" + curItemSiteName;
//Create the subsite based on the template from the Solution Gallery
SPWeb newSite = spCurrentSite.Webs.Add(curItemSiteName, curItemSiteName, curItemDescription, Convert.ToUInt16(1033), "WIKI#0", false, false);
//Set the new subsite to inherit it's top navigation from the parent site, Usefalse if you do not want this.
newSite.Navigation.UseShared = true;
CreateList(newSite);
newSite.Close();
}
}
此代码适用于场解决方案。对于沙箱解决方案,它给出了例外: SPWeb newSite = spCurrentSite.Webs.Add(curItemSiteName,curItemSiteName,curItemDescription,Convert.ToUInt16(1033)," WIKI#0",false,false);
表示沙盒代码执行请求被拒绝,因为沙盒代码主机服务太忙而无法处理请求。"
有什么建议吗?