SharePoint: The security validation for this page is invalid

Today I found myself running into the ‘famous’ “The security validation for this page
is invalid” error and it cost me quite some stress figuring out what went wrong, and
why I wasn’t allowed to do what I wanted, a simple change to a user profile.

The thing is that everything worked fine, until I actually added the UserProfile.Commit()
to apply the changes to my profile. So after some searching the web for something
that could help me further (besides the run with elevated privileges), and some help
from my colleague Peter we found the following
article: The
security validation for this page is invalid

Basically the idea is: forget the AllowUnsafeUpdates(); and add a FormDigestControl
to the page you are working on, as you can see it only takes a reference:

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

And a control:

<SharePoint:FormDigest runat=server/>

Further info can be found on the mentioned blog.

Leave a Reply