We have a custom web service, which among other things adds new links to the user personal site. This web service is deployed in _vti_bin folder is throwing the following error while attempting to add links to users quick links:
Microsoft.SharePoint.SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. ---> System.Runtime.InteropServices.COMException (0x8102006D): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
at Microsoft.SharePoint.Library.SPRequestInternalClass.ValidateFormDigest(String bstrUrl, String bstrListName)
at Microsoft.SharePoint.Library.SPRequest.ValidateFormDigest(String bstrUrl, String bstrListName)
--- End of inner exception stack trace ---
at Microsoft.SharePoint.Library.SPRequest.ValidateFormDigest(String bstrUrl, String bstrListName)
at Microsoft.SharePoint.SPWeb.ValidateFormDigest()
at Microsoft.SharePoint.Utilities.SPUtility.ValidateFormDigest()
at Microsoft.Office.Server.UserProfiles.PrivacyItem.Commit()
at Microsoft.Office.Server.UserProfiles.QuickLink.Commit()
at Microsoft.Office.Server.UserProfiles.QuickLink..ctor(UserProfile ownerProfile, String strTitle, String strUrl, QuickLinkGroupType groupType, String strGroup, Privacy privacyLevel)
at Microsoft.Office.Server.UserProfiles.QuickLinkManager.Create(String strTitle, String strUrl, QuickLinkGroupType groupType, String strGroup, Privacy privacyLevel)
Following is the snippet of code from the web method:
UserProfileManager userProfileMgr = new UserProfileManager(ServerContext.GetContext(SPContext.Current.Web.Site));
if (userProfileMgr.UserExists(userAcct))
{
UserProfile uProfile = userProfileMgr.GetUserProfile(userAcct, true);
QuickLink link1 = uProfile.QuickLinks.Create(title, url, QuickLinkGroupType.UserSpecified, AddLinkDefaultGroup, Privacy.Private);
}
I have tried setting the AllowUnsafeUpdates on both the site as well as webapplication from SPContext but to no avail. Any pointers or help will be truly appreciated.