I'm working on developing a custom action which sets a custom site property and
the site theme (the combination is being used as kind of a visual security
marker for sites). I have developed the aspx page and code-behind. When I
initially created the code to change the site property it worked fine. I added
the call to set the theme, but I get the following error when it runs: {"The
security validation for this page is invalid. Click Back in your Web browser,
refresh the page, and try your operation again."}.
I've tried allowing unsafe updates and elevated privileges but can't get rid of
the error. Any ideas as to what is causing the problem? How can I get around
this? Below is a copy of the code-behind where the error occurs.
ThmxTheme.SetThemeUrlForWeb(this.Web, "/_catalogs/theme/esBlue1.thmx");