팜 솔루션으로 배포 한 사용자 지정 SharePoint 웹 파트가 있고 SharePoint 목록에 쓰는 데 문제가 있습니다. 많은 다른 장소에서 AllowUnsafeUpdates를 True로 설정하고 SPListItem 업데이트를 호출하기 전에 SPWeb 개체를 업데이트하더라도 프로그래밍 방식으로 목록에 쓸 때 발생하는 오류 메시지는 다음과 같습니다.사용자 지정 웹 파트의 "GET 요청시 업데이트가 현재 허용되지 않습니다."
GET 요청에 대한 업데이트가 현재 허용되지 않습니다. . GET에서 업데이트를 허용하려면 SPWeb에서 'AllowUnsafeUpdates'속성을 설정하십시오.
나는 또한 RunWithElevatedPrivileges를 사용해 보았지만 행운은 없다.
public void WriteError(string errorTask, string errorMessage)
{
string task = "Error Log Entry";
string fileName = "";
string fileTitle = "";
string fileType = "";
using (SPSite oSiteCollection = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb oWebsite = oSiteCollection.RootWeb)
{
oSiteCollection.AllowUnsafeUpdates = true;
oWebsite.AllowUnsafeUpdates = true;
oWebsite.Update();
SPSite errorLogSite = new SPSite(oWebsite.ServerRelativeUrl);
SPListItemCollection oList = errorLogSite.RootWeb.Lists["ErrorLog"].Items;
SPListItem oItem = oList.Add();
oItem["ErrorTask"] = task + ": " + errorTask;
oItem["ErrorMessage"] = errorMessage;
oItem["UserName"] = String.IsNullOrEmpty(UserName) ? "Not Available" : UserName;
oItem["FileName"] = String.IsNullOrEmpty(fileName) ? "Not Available" : fileName;
oItem["Title"] = String.IsNullOrEmpty(fileTitle) ? "Not Available" : fileTitle;
oItem["FileType"] = String.IsNullOrEmpty(fileType) ? "Not Available" : fileType;
oItem.Update();
}
}
}
관련없는,하지만 당신은 자신의 사이트 모음을 만들로 여기 해치지 않을 것입니다 ('spSiteCollection.RootWeb'을 폐기하지 않지만, 규칙이처럼하지 해); 또한'AllowUnsafeUpdates'는'SPWeb'의 _instance_에있는 속성이므로'Update'를 요구하지 않습니다. 하지만 Oleg는 귀하의 실제 질문에 대한 올바른 대답을 가지고 있다고 생각합니다. – Rawling
이 웹 파트를 사용자 정의 페이지에서 호스팅하고 있습니까? –