Sharepoint 2007 sharepoint对象建模
您可能正在SharePoint外部运行代码,或者在初始化SPContext(例如HTTP处理程序)之前运行代码。将真实url放入代码中,您可以这样使用它:Sharepoint 2007 sharepoint对象建模,sharepoint-2007,Sharepoint 2007,您可能正在SharePoint外部运行代码,或者在初始化SPContext(例如HTTP处理程序)之前运行代码。将真实url放入代码中,您可以这样使用它: protected void btnCreateList_Click(object sender, EventArgs e) { SPWeb currentWeb = SPContext.Current.Web; Guid webId = currentWeb.ID; Guid siteId = currentWe
protected void btnCreateList_Click(object sender, EventArgs e)
{
SPWeb currentWeb = SPContext.Current.Web;
Guid webId = currentWeb.ID;
Guid siteId = currentWeb.Site.ID;
Response.Write(siteId);
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteId))
{
using (SPWeb web = site.OpenWeb(webId))
{
site.AllowUnsafeUpdates = true;
Response.Write("configured successfully");
}
}
});
}
请提供更多详细信息,请使用更多代码或解释更新您的问题。我正在尝试在不使用runwith deleted选项的情况下运行代码,但它会带来一些安全许可限制。所以我必须使用run with delegated Option你的用户拥有什么样的权限?看看这个,也许会有帮助
using(SPSite oSiteCollection = new SPSite("http://Your_Server_Name"))
{
using(SPWeb oWebsite = oSiteCollection.OpenWeb("Your_Website_URL"))
{
using(SPWeb oWebsiteRoot = oSiteCollection.RootWeb)
{
...
}
}
}