0
我有這樣的代碼來創建有條件SharePoint列表(排序的UPSERT的):爲什麼這被認爲是Sharepoint中的「不安全更新」?
private void ConditionallyCreateList()
{
SPWeb site = SPContext.Current.Web;
// Check to see if list already exists; if so, exit
if (site.Lists.TryGetList(listTitle) != null) return;
SPListCollection lists = site.Lists;
SPListTemplateType listTemplateType = new SPListTemplateType();
listTemplateType = SPListTemplateType.GenericList;
string listDescription = "This list retains vals inputted for the Post Travel form";
Guid ListId = lists.Add(listTitle, listDescription, listTemplateType);
. . .
這個工作時,首先創建,並在應用程序的後續execustions。
不過,我做了一些激進的重構到列表結構,並刪除了舊的,所以(我希望)一個新的具有新的結構將被創建。然而,而不是讓一個重構的名單,我得到這個在最後一行如上圖所示:
Microsoft.SharePoint.SPException was unhandled by user code
Message=Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.
我能夠通過添加指定的代碼來解決此問題:
site.AllowUnsafeUpdates = true;
...但爲什麼這是必要的嗎?爲什麼創建一個不應該存在的列表(我從Sharepoint「所有網站內容」bazaar中刪除它)有問題(可能是一個'不安全的更新')?