代码引发 Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem 安全性驗證無效

本文針對使用SharePoint時出現的安全性驗證無效問題提供了具體解決方案,通過修改代碼允許不安全更新來避免錯誤發生。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码引发 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();
}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值