【发布时间】:2011-01-20 01:25:03
【问题描述】:
我将 SharePoint Server 2007 Enterprise 与 Windows Server 2008 Enterprise 一起使用。我已经部署了一个发布门户。我正在使用 VSTS 2008 + C# + .Net 3.5 + ASP.Net + SharePoint Server 2007 SDK 开发一个 ASP.Net Web 应用程序。
这是我的代码 sn-ps,我收到错误 - “当前不允许对 GET 请求进行更新”。任何想法如何解决?
Microsoft.SharePoint.SPException: Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.
protected void Page_Load(object sender, EventArgs e)
{
try
{
SPWebApplication webApp = SPContext.Current.Site.WebApplication;
SPSiteCollection siteCollections = webApp.Sites;
foreach (SPSite item in siteCollections)
{
SPWeb webItem = item.OpenWeb();
webItem.AllowUnsafeUpdates = true;
}
SPSite newSiteCollection = siteCollections.Add("sites/myblog",
"New Sample Site", "New Sample Site Description", 1033, "BLOG#0",
"foo\\foouser", "Owner name", "owneremail@foo.com");
}
catch (Exception ex)
{
Response.Write(ex.ToString() + "\t" + ex.StackTrace);
}
}
【问题讨论】:
标签: c# asp.net .net visual-studio-2008 sharepoint-2007