SharePoint 工作流中的无效安全验证异常

发布于 2024-08-28 13:04:37 字数 732 浏览 4 评论 0原文

我的 SharePoint 工作流遇到了奇怪的安全问题。特定的调用似乎会导致以下异常:

Microsoft.SharePoint.SPException: 该页面的安全验证是 无效。

我以前遇到过这个错误,简单的修复方法是

web.AllowUnsafeUpdates = true;
...
web.AllowUnsafeUpdates = false;

但是,自从工作流程作为系统运行以来,我以前从未在工作流程中遇到过这个问题。我首先在代码活动中遇到此错误,其中我设置了列表项上的列的值。将 item.Update 包装在AllowUnsafeUpdates 中修复了该问题。

在代码活动之后,我有一个 CreateTask 活动。这也会导致相同的错误,但仅在运行活动的 MethodInvoking 内的代码之后才会发生。

在这两种情况下,堆栈跟踪中都会涉及 SPListItem.UpdateItem。此呼叫未通过安全检查。我不知道这项检查是如何运作的,所以我不知道下一步该去哪里。

这是一个奇怪的情况,因为这台 SharePoint 开发机器已经正常工作了一段时间了。没有其他项目或工作流程表现出此行为,因此排除了安装问题。这个特定的工作流程有一些东西。

[更新] 我通过创建一个新项目并再次构建它来解决这个问题。我还留着那个坏掉的,我仍然想找出它的问题所在。如果有任何关于它可能是什么的建议,我将不胜感激。

I'm having a strange security problem with a SharePoint workflow. Particular calls seem to result in the following exception:

Microsoft.SharePoint.SPException: The
security validation for this page is
invalid.

I've come across this error before and the simple fix is

web.AllowUnsafeUpdates = true;
...
web.AllowUnsafeUpdates = false;

However I've never once encountered this problem inside a workflow before since a workflow runs as system. I first got this error in a code activity where I set the value of a column on the list item. Wrapping the item.Update in AllowUnsafeUpdates fixed it.

After the code activity I have a CreateTask activity. This also causes the same error but only after running the code inside the activity's MethodInvoking.

In both cases there's a SPListItem.UpdateItem involved within the stack trace. This call is failing a security check. I don't know anything about how this check works so I don't know where to look next.

This is a strange one, because this SharePoint dev machine has been working fine for some time. No other projects or workflows exhibit this behaviour so that rules out an installation problem. There's just something about this particular workflow.

[UPDATE]
I've gotten around the issue by just creating a new project and building it up again. I still have the broken one and I'd still like to figure out the problem with it. I'd appreciate any suggestions of what it might be.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别闹i 2024-09-04 13:04:37

我还没有在工作流程中看到这种情况发生,但我见过两种情况。也许其中之一会有所帮助。

  1. 在 SharePoint 页面的 GET 上而不是在 POST 上更新项目(即 Page.IsPostBack 为 false)。将AllowUnsafeUpdates 设置为true 可以修复此问题。
  2. 模拟或以提升的权限运行时更新 SharePoint 页面的 POST 上的项目。调用 SPUtility.ValidateFormDigest 修复它。

I haven't seen this happen in a workflow, but there are two cases where I have seen it. Maybe one of those will be helpful.

  1. Updating an item on the GET of a SharePoint page instead of on the POST (ie, Page.IsPostBack is false). Setting AllowUnsafeUpdates to true fixes it.
  2. Updating an item on the POST of a SharePoint page when impersonating or running with elevated privileges. Calling SPUtility.ValidateFormDigest fixes it.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文