Invalid security validation exception inside a SharePoint workflow

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.


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.

Need Your Help

Can't horizontal center div in parent

css html center

I have some divs set up as navigation buttons and I have put all the buttons into a div and then put that div into another "holder" div. the problem is that I can't seem to center the div that hold...

create database using sudo mysql -u=root

mysql database linux shell ubuntu

I am having problem rightnow because when I am logging in on mysql using command line via mysql -u=root it gives me an error like this ERROR 2002 (HY000): Can't connect to local MySQL server through