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
security validation for this page is invalid]2.
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=184.108.40.206, Culture=neutral, PublicKeyToken=71e9bce111e9429c”
And a control:
Further info can be found on the mentioned blog.