C# 当前不允许对GET请求进行更新。关于复制文档集

C# 当前不允许对GET请求进行更新。关于复制文档集,c#,sharepoint,C#,Sharepoint,我已经尝试了所有关于这个问题的方法,但是找不到错误 我的网站的结构是这样的 会议(网站集、RootWeb) 1.1董事会(子网站) 1.1.1 20101(子网站) 1.1.2 20120202(子网站) 在会议中有一个叫做会议的列表。在每个子网站中都有一个名为“议程点和文档集”的列表 我创建了一个自定义操作,将议程点从一个会议地点复制到下一个会议地点 我在CopyTo方法中遇到以下异常。如您所见,我将allowunsafeupdates设置为true。我错过了什么 当前不允许对GET请求进行更

我已经尝试了所有关于这个问题的方法,但是找不到错误

我的网站的结构是这样的

会议(网站集、RootWeb)

1.1董事会(子网站)

1.1.1 20101(子网站)

1.1.2 20120202(子网站)

在会议中有一个叫做会议的列表。在每个子网站中都有一个名为“议程点和文档集”的列表

我创建了一个自定义操作,将议程点从一个会议地点复制到下一个会议地点

我在CopyTo方法中遇到以下异常。如您所见,我将allowunsafeupdates设置为true。我错过了什么

当前不允许对GET请求进行更新。要允许对GET进行更新,请在SPWeb上设置“AllowUnsafeUpdates”属性

protected void Page_Load(object sender, EventArgs e)
        {
            Logger.LogDebug("CopyAgendaPointToNextMeetingWithAttachments", "Page_Load(object sender, EventArgs e)", "BEGIN");

            string source = Request.Url.ToString();
            string state = Request.GetQueryStringValue(MeetingsCommon.Constants.QUERYSTRINGPARAMETER_STATE_NAME);
            string statusMessage = Request.GetQueryStringValue(MeetingsCommon.Constants.QUERYSTRINGPARAMETER_MESSAGE_NAME);
            this.litMessage.Text = statusMessage;

            if (!string.IsNullOrEmpty(state))
                return;

            using (SPLongOperation operation = new SPLongOperation(this.Page))
            {
                SPWeb currentWeb = SPContext.Current.Web;
                SPSite currentSite = currentWeb.Site;
                try
                {                    
                    operation.Begin();
                    currentSite.WebApplication.FormDigestSettings.Enabled = false;
                    currentSite.RootWeb.AllowUnsafeUpdates = true;
                    currentWeb.AllowUnsafeUpdates = true;  

                    string listID = Request.QueryString[MeetingsCommon.Constants.QUERYSTRINGPARAMETER_LISTID_NAME];
                    string listItemID = Request.QueryString[MeetingsCommon.Constants.QUERYSTRINGPARAMETER_ID_NAME];  
                    string webappUrl = currentSite.WebApplication.GetResponseUri(currentSite.Zone).ToString();
                    source = source.Replace(webappUrl.ToLower(), currentWeb.Url.ToLower() + "/");

                    SPSecurity.RunWithElevatedPrivileges(() =>
                    {
                        SPList currentList = currentWeb.GetSafeListByGuid(new Guid(listID));
                        SPListItem item = currentList.GetItemById(Convert.ToInt32(listItemID));
                        SPWeb siteCollectionRootWeb = currentWeb.ParentWeb.ParentWeb.Site.RootWeb;
                        string type = currentWeb.Name.Substring(0, 2);
                        SPList listMeetingsRoot = siteCollectionRootWeb.GetSafeListByName(Meetings.Common.Constants.LISTS_MEETINGCALENDAR_NAME);


                        SPQuery query = new SPQuery();
                        query.Query = string.Concat(
                            "<Where>",
                            "<And>",
                            "<BeginsWith>",
                                "<FieldRef Name='" + Meetings.Common.Constants.FIELDS_TEXT_TITLE_NAME + "' />",
                                "<Value Type='Text'>" + type + "</Value>",
                            "</BeginsWith>",
                            "<Gt>",
                                " <FieldRef Name='" + Meetings.Common.Constants.FIELDS_EVENTDATE_NAME + "' />",
                                "<Value Type='DateTime'><Today /></Value>",
                            "</Gt>",                                   
                            "</And>",
                            "</Where>");
                        query.RowLimit = 1;

                        SPListItemCollection itemsMeetings = listMeetingsRoot.GetItems(query);
                        if (itemsMeetings.Count == 1)
                        {
                            SPFieldUrlValue value = new SPFieldUrlValue(itemsMeetings[0][Meetings.Common.Constants.FIELDS_MEETINGSITEURL_NAME].ToString());
                            string urlOfNextMeetingSite = value.Url;
                            using (SPSite nextMeetingSite = new SPSite(urlOfNextMeetingSite))
                            {
                                using (SPWeb nextMeetingWeb = nextMeetingSite.OpenWeb())
                                {
                                    try
                                    {
                                        nextMeetingSite.RootWeb.AllowUnsafeUpdates = true;
                                        nextMeetingWeb.ParentWeb.AllowUnsafeUpdates = true;
                                        nextMeetingWeb.AllowUnsafeUpdates = true;
                                        SPList targetList = nextMeetingWeb.GetSafeListByName(MeetingsCommon.Constants.LISTS_AGENDAPOINTS_NAME);
                                        SPDocumentLibrary targetDocumentLibrary = nextMeetingWeb.GetSafeDocumentLibraryByName(MeetingsCommon.Constants.LISTS_AGENDAPOINTS_NAME);
                                        SPContentTypeId targetCTId = targetList.ContentTypes.BestMatch(new SPContentTypeId(MeetingsCommon.Constants.CONTENTTYPES_AGENDAPOINT_ID));
                                        string id = itemsMeetings[0]["UniqueId"].ToString();

                                        DocumentSet sourceDocumentSet = DocumentSet.GetDocumentSet(item.Folder);
                                        DocumentSet targetDocumentSet = null;
                                        if (sourceDocumentSet != null)
                                        {
                                            targetDocumentSet = sourceDocumentSet.CopyTo(targetList.RootFolder, targetCTId);
                                            SPListItem destinationListItem = targetDocumentSet.Item;
                                            destinationListItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTSRECURRENT_NAME] = "False";
                                            destinationListItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTSCOPYATTACHMENTS_NAME] = "False";
                                            destinationListItem.Update();
                                            statusMessage = string.Format(HelperFunctions.GetResourceString(MeetingsCommon.Constants.RESOURCES_FILE_NAME, "Message_CopyAgendaPoint"), nextMeetingWeb.Url, nextMeetingWeb.Name);
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        throw;
                                    }
                                    finally
                                    {
                                        nextMeetingWeb.AllowUnsafeUpdates = false;
                                        nextMeetingWeb.ParentWeb.AllowUnsafeUpdates = false;
                                        nextMeetingSite.RootWeb.AllowUnsafeUpdates = false;
                                    }                                    
                                }
                            }
                        }
                        else
                        {
                            statusMessage = HelperFunctions.GetResourceString(MeetingsCommon.Constants.RESOURCES_FILE_NAME, "Message_CopyAgendaPointNoNextSiteFound");
                        }
                    });
                }
                catch (Exception ex)
                {
                    Logger.LogError("CopyAgendaPointToNextMeetingWithAttachments", "Page_Load(object sender, EventArgs e)", ex);
                    statusMessage = ex.Message;
                }
                finally
                {
                    statusMessage = HttpUtility.UrlEncode(statusMessage);                                    
                    currentWeb.AllowUnsafeUpdates = false;
                    currentSite.RootWeb.AllowUnsafeUpdates = false;
                    currentSite.WebApplication.FormDigestSettings.Enabled = true;   
                    operation.End(source, Microsoft.SharePoint.Utilities.SPRedirectFlags.DoNotEncodeUrl, HttpContext.Current, "&state=completed&message=" + statusMessage);
                }
                Logger.LogDebug("CopyAgendaPointToNextMeetingWithAttachments", "Page_Load(object sender, EventArgs e)", "END");
            }
        }
受保护的无效页面加载(对象发送方,事件参数e)
{
LogDebug(“CopyAgendaPointToNextMeetingWithAttachments”,“Page_Load(objectsender,EventArgs e)”,“BEGIN”);
string source=Request.Url.ToString();
字符串状态=Request.GetQueryStringValue(MeetingsCommon.Constants.QUERYSTRINGPARAMETER\u state\u NAME);
string statusMessage=Request.GetQueryStringValue(MeetingsCommon.Constants.QUERYSTRINGPARAMETER\u消息\u名称);
this.litMessage.Text=状态消息;
如果(!string.IsNullOrEmpty(状态))
返回;
使用(SPLongOperation=新的SPLongOperation(this.Page))
{
SPWeb currentWeb=SPContext.Current.Web;
SPSite currentSite=currentWeb.Site;
尝试
{                    
Begin()操作;
currentSite.WebApplication.FormDigestSettings.Enabled=false;
currentSite.RootWeb.AllowUnsafeUpdates=true;
currentWeb.AllowUnsafeUpdates=true;
string listID=Request.QueryString[MeetingsCommon.Constants.QUERYSTRINGPARAMETER\u listID\u NAME];
string listItemID=Request.QueryString[MeetingsCommon.Constants.QUERYSTRINGPARAMETER\u ID\u NAME];
字符串webappUrl=currentSite.WebApplication.GetResponseUri(currentSite.Zone.ToString();
source=source.Replace(webappUrl.ToLower(),currentWeb.Url.ToLower()+“/”;
SPSecurity.RunWithElevatedPrivileges(()=>
{
SPList currentList=currentWeb.GetSafeListByGuid(新Guid(listID));
SPListItem=currentList.GetItemById(Convert.ToInt32(listItemID));
SPWebSiteCollectionRootWeb=currentWeb.ParentWeb.ParentWeb.Site.RootWeb;
字符串类型=currentWeb.Name.Substring(0,2);
SPList listMeetingsRoot=siteCollectionRootWeb.GetSafeListByName(Meetings.Common.Constants.LISTS\u MEETINGCALENDAR\u NAME);
SPQuery query=新建SPQuery();
query.query=string.Concat(
"",
"",
"",
"",
“”+类型+“”,
"",
"",
" ",
"",
"",                                   
"",
"");
query.RowLimit=1;
SPListItemCollection itemsMeetings=listMeetingsRoot.GetItems(查询);
if(itemsMeetings.Count==1)
{
SPFieldUrlValue=new SPFieldUrlValue(itemsMeetings[0][Meetings.Common.Constants.FIELDS\u MEETINGSITEURL\u NAME].ToString());
字符串urlOfNextMeetingSite=value.Url;
使用(SPSite nextMeetingSite=新SPSite(urlOfNextMeetingSite))
{
使用(SPWeb nextMeetingWeb=nextMeetingSite.OpenWeb())
{
尝试
{
nextMeetingSite.RootWeb.AllowUnsafeUpdates=true;
nextMeetingWeb.ParentWeb.AllowUnsafeUpdates=true;
nextMeetingWeb.AllowUnsafeUpdates=true;
SPList targetList=nextMeetingWeb.GetSafeListByName(MeetingsCommon.Constants.List\u AGENDAPOINTS\u NAME);
SPDocumentLibrary targetDocumentLibrary=nextMeetingWeb.GetSafeDocumentLibraryByName(MeetingsCommon.Constants.List\u AGENDAPOINTS\u NAME);
SPContentTypeId targetCTId=targetList.ContentTypes.BestMatch(新的SPContentTypeId(MeetingsCommon.Constants.ContentTypes_AGENDAPOINT_ID));
字符串id=itemsMeetings[0][“UniqueId”].ToString();
DocumentSet sourceDocumentSet=DocumentSet.GetDocumentSet(item.Folder);
DocumentSet targetDocumentSet=null;
如果(sourceDocumentSet!=null)
{
targetDocumentSet=sourceDocumentSet.CopyTo(targetList.RootFolder,targetCTId);
SPListItem destinationListItem=targetDocumentSet.Item;
destinationListItem[MeetingsCommon.Constants.FIELDS\u AgendaPoints当前\u NAME]=“False”;
destinationListItem[MeetingsCommon.Constants.FIELDS\u AGENDAPOINTSCOPYATTACHMENTS\u NAME]=“False”;