How to resolve "The security validation for this page is invalid" error in SharePoint 2010
It may possible many time when you are running custom code in SharePoint's context you are getting the following error:
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:
This error can be thrown for different reason but the prominent one that I noticed is when some list/ library edit/ update operation happens in the code and SharePoint tries to protect unsafe updates to its list/ libraries.
To resolve the same error in such cases you need to put your code between the following code stub:
Now rebuild the solution and deploy and test again!