代码引发 Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem 安全性驗證無效
SPSite mySeite = null;
SPWeb myWeb = null;
try
{
mySeite = new SPSite(_siteUrl);
myWeb = mySeite.OpenWeb();
SPList myList = myWeb.Lists[new Guid(this._ms.ListID)];
//Guid = new Guid();
SPListItem spfolder = myList.Folders[new Guid(this._ms.FolderID)];
SPFolder spfolderA = spfolder.Folder;
spfolderA.Item["是否發送"] = true;
//spfolder["是否發送"] = true;
spfolderA.Item.Update();
spfolderA.Update();
}
catch (Exception EailException)
{
F_MailSend("softadmin@delta.com.cn", "cheng.cheng@delta.com.cn", "EailException", "" + EailException.Message + "<br>" + EailException.StackTrace+" <br> line 1278");
}
finally
{
if (mySeite != null)
{
mySeite.Dispose();
}
if (myWeb != null)
{
myWeb.Dispose();
}
}
對於這個網頁的安全性驗證無效。請按一下網頁瀏覽器的 [上一頁],重新整理頁面,然後再次嘗試作業。
於 Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish) 於 Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents) 於 Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) 於 Microsoft.SharePoint.SPListItem.Update()
解决之道(注意红字部分):
SPSite mySeite = null;
SPWeb myWeb = null;
try
{
mySeite = new SPSite(_siteUrl);
myWeb = mySeite.OpenWeb();
SPList myList = myWeb.Lists[new Guid(this._ms.ListID)];
//Guid = new Guid();
SPListItem spfolder = myList.Folders[new Guid(this._ms.FolderID)];
SPFolder spfolderA = spfolder.Folder;
myWeb.AllowUnsafeUpdates = true;//该代码表示允许代码更新
spfolderA.Item["是否發送"] = true;
//spfolder["是否發送"] = true;
spfolderA.Item.Update();
spfolderA.Update();
}
catch (Exception EailException)
{
F_MailSend("softadmin@delta.com.cn", "cheng.cheng@delta.com.cn", "EailException", "" + EailException.Message + "<br>" + EailException.StackTrace+" <br> line 1278");
}
finally
{
if (mySeite != null)
{
mySeite.Dispose();
}
if (myWeb != null)
{
myWeb.Dispose();
}
}