我遇到了非常奇怪的错误,在过去的几个小时里解决了这个问题
“当前不允许对 GET 请求进行更新。要允许对 GET 进行更新,请在 SPWeb 上设置 'AllowUnsafeUpdates' 属性。”
Public Shared Sub DeleteListItem(ByVal listname As SPList, ByVal intItemID As Integer)
Using MySite As New SPSite(SPContext.GetContext(System.Web.HttpContext.Current).Web.Url)
Using MyWeb As SPWeb = MySite.OpenWeb()
MyWeb.AllowUnsafeUpdates = True
Dim itemColforGivenList As SPListItemCollection
Dim query As New SPQuery()
query.Query = "<Where><Eq><FieldRef Name='ID'/><Value Type='Counter'>" &
intItemID & "</Value></Eq></Where>"
MyWeb.AllowUnsafeUpdates = True
itemColforGivenList = listname.GetItems(query)
If itemColforGivenList.Count > 0 Then
For i As Integer = listname.Items.Count - 1 To 0 Step -1
If listname.Items(i).ID = intItemID Then
MyWeb.AllowUnsafeUpdates = True
listname.Items.Delete(i)
listname.Update()
MyWeb.AllowUnsafeUpdates = False
End If
Next
End If
End Using
End Using
请帮帮我