Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb
2009-01-17 14:04
846 查看
问题描述:
通过SPList.Update()可以更新一个List,但一般你是不能直接调用此方法的,会出现“Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.”[/b]
解决方法有两个:
1.设置AllowUnsafeUpdates = true.这是个很取巧的方法,不只这里可以使用,在由于其他一些原因导致以上错误的时候只要设置此值,错误就可避免。我看到过有些工程里只要涉及到SPWeb,必设置此值。但是它是有安全隐患的,具体解释可以参考MSDN。2. 不要使用Get requests而使用Post requests,配合使用RunWithElevatedPrivileges,也可以有效解决这个问题。所谓不要使用Get requests而使用 Post requests,简单的说就是你不要直接在Page_Load这种事件里去Update list,你可以放一个Button,使用它来触发事件。然后把Update 代码放在RunWithElevatedPrivileges中执行。
string url = SPContext.Current.Site.Url;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(url))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[ListName];
list .Update();
}
}
}
);
一般情况下都能满足需要。
相关文章推荐
- Updates are current disallowed on get requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWe
- MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error
- #Redis Error #MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details a
- MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error
- error C4996: Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct
- file输入框不允许js设置值 Failed to set the 'value' property on 'HTMLInputElement
- Parsing Failure in config.xml: java.lang.IllegalArgumentException: In production mode, it's not allowed to set a clear text value to the property
- Failed to set the 'value' property on 'HTMLInputElement': This input element解决办法
- [BTS] Correct the specified Action, or refer to the documentation on the allowed formats for the Actions. Note that Actions are case-sensitive.
- Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUp
- Jquery 报错 Uncaught InvalidStateError: Failed to set the 'value' property on 'HTMLInputElement':
- Whoops! Sorry, but you are not allowed to perform the action requested.
- Set TOProperty,Get TOProperty,Get ROProperty区别
- 老生常谈--GetROProperty,GetTOProperty,SetTOProperty的区别
- Failed to access the USB subsystem.VirtualBox is not currently allowed to access USB devices...
- 使用FABridge时,出现You are trying to call recursively into the Flash Player which is not allowed…错误的处理
- ORA-30926: unable to get a stable set of rows in the source tables
- iOS-Failed to set (placeholder) user defined inspected property on (UITextView)
- Both must set "document.domain" to the same value to allow access.
- 在PL/SQL 里面有把锁一样的按钮,点击它会跳出“these query result are not updateable,include the ROWID to get updateab