Thursday, August 28, 2008

The security validation for this page is invalid

Error:

I received the following error while uploading files to a sharepoint document library from an asp.net application.
The security validation for this page is invalid. Click Back in your Web
browser, refresh the page, and try your operation again
Resolution:

Add following lines of code before the Update() method on SPFolder is called.

site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;

Wednesday, August 27, 2008

Multiple Copies of Sharepoint Web application

To create multiple copies of a web application on a webfarm the database backup-restore will not work as the GUID of site will be same. The following process is useful in that scenario:


  • Back up using stsadm stsadm -o backup -url <original site url> -filename <backup file path>\db.bak
  • Create new web application (and content database) using Central Admin
  • Restore (and overwrite) using stsadm stsadm -o restore -url <new site url> -filename <backup file path>\db.bak -overwrite