开发者

Content Deployment and AllowUnsafeUpdates

开发者 https://www.devze.com 2022-12-08 23:25 出处:网络
I have this bit of code... using (SPSite sitecollection = new SPSite(siteUrl)) { using (SPWeb web = sitecollection.OpenWeb(webUrl))

I have this bit of code...

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;
        }
    }
}

which should add an item to the content deployment for the specified web. However I get this error...

Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUp开发者_StackOverflowdates' property on SPWeb.

yet i've set AllUnsafeUpdates to true. Is it me, am I missing something?


Did you try running web.update() before running the contentDeploymentJob? It looks to me that you are setting the property but not saving it.

0

精彩评论

暂无评论...
验证码 换一张
取 消