Я использую ajax для вызова веб-службы, которая обновляет список sharepoint.
Это работает, когда я вызываю код из модульных тестов, но запуск кода в браузере вызывает исключение:
System.InvalidOperationException: операция недопустима из-за текущего состояния объекта.в Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl (контекст HttpContext) в Microsoft.SharePoint.WebControls.SPControl.GetContextWeb (контекст HttpContext) в Microsoft.SharePoint.SPContext.get_Current ().Логическое bSystem, булева bPreserveItemVersion, булева bNoVersion, булева bMigration, булева bPublish, булева bCheckOut, булева bCheckin, Guid newGuidOnAdd, Int32 & ulID, объект и objAttachmentNames, объект и objAttachmentContents, Boolean suppressAfterEvents) при Microsoft.SharePoint.SPListItem.UpdateInternal (булево bSystem, булева bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) в Microsoft.SharePoint.SPListItem.Update ()
* 1008 - обновить список * до 1007 *
1009 *
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteURL))
{
using (SPWeb web = site.OpenWeb(path))
{
SPList userProfile = web.Lists[userList];
SPQuery qry = new SPQuery
{
Query =
"<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" +
accountName +
"</Value></Eq></Where><ViewFields><FieldRef Name='ID' /><FieldRef Name='Title' /><FieldRef Name='LastUpdated' /><FieldRef Name='Reason' /></ViewFields>"
};
SPListItemCollection spListItemCollection = userProfile.GetItems(qry);
if (spListItemCollection.Count == 1)
{
//edit user
SPListItem item = spListItemCollection[0];
item["Updated"] = DateTime.Now;
item["Reason"] = updateReason;
item.Update();
}
}
}
});
Это ошибки на item.Update ();