内容部署和AllowUnsafeUpdates

时间:2009-10-22 11:14:20

标签: sharepoint sharepoint-2007

我有这段代码......

using (SPSite sitecollection = new SPSite(siteUrl))
{
    using (SPWeb web = sitecollection.OpenWeb(webUrl))
    {
        try
        {                        
            web.AllowUnsafeUpdates = true;

            ContentDeploymentJob.AddQuickDeployObject(web,
                        Microsoft.SharePoint.Deployment.SPDeploymentObjectType.ListItem,
                        itemUrl);                        
            web.Update();
        }
        finally
        {
            web.AllowUnsafeUpdates = false;
        }
    }
}

应该将项添加到指定Web的内容部署中。 但是我收到了这个错误......

  

GET请求目前不允许更新。要允许GET上的更新,请在SPWeb上设置“AllowUnsafeUpdates”属性。

但我已将AllUnsafeUpdates设置为true。是我吗,我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

您是否在运行contentDeploymentJob之前尝试运行web.update()?它在我看来你正在设置属性但不保存它。