首页 > Windows开发 > 详细

Web API,Web Service SharePoint对象操作报Operation is not valid due to the current state of the object解决方案

时间:2017-03-30 17:04:28      阅读:200      评论:0      收藏:0      [点我收藏+]

Web API,Web Service SharePoint对象操作报Operation is not valid due to the current state of the object解决方案,这是因为当前的user信息不一致导致的,添加HttpContext.Current = null;,解决,要类似这样:

SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                HttpContext.Current = null;
                using (SPSite site = new SPSite(targetWeb))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList targetlist = web.Lists[targetList];
                        foreach (ItemType item in import.item)
                        {
   ...
                        }
                    }
                }
            });

Web API,Web Service SharePoint对象操作报Operation is not valid due to the current state of the object解决方案

原文:http://www.cnblogs.com/gamewyd/p/6646896.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!