Hi,I'm going to restore a site collection pragmatical. So when user click the CreateNewClient button, It should restore a new site collection named Site1. ( this site collection doesn't exist)
Here is the code:
#region CreateNewClient3
protected void CreateNewClient3_Click(object sender, EventArgs e)
{
try
{
string sitecollectionURL = "http://ad/sites/site1";
string backupfilename = @"E:\\Clientn.bak";
SPWebApplication parentWebApp;
using (SPSite siteCol = new SPSite(sitecollectionURL))
{
parentWebApp = siteCol.WebApplication;
}
parentWebApp.Sites.Restore(sitecollectionURL, backupfilename, true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
#endregion and for backup:
#region Backup
protected void Backup_Click(object sender, EventArgs e)
{
try
{
string sitecollectionURL = "http://ad/sites/ClientTest";
string backupfilename = @"E:\\Clientn.bak";
SPWebApplication parentWebApp;
using (SPSite siteCol = new SPSite(sitecollectionURL))
{
parentWebApp = siteCol.WebApplication;
}
parentWebApp.Sites.Backup(sitecollectionURL, backupfilename, true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
#endregionBackup is working fine but Restore button doesn't work and I get the following error:
The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
I login with administrator (Full permission) and I've checked web.config : trust level="Full"
<trust level="Full" originUrl="" legacyCasModel="true" />
<webParts>
but I still get Access denied
Could you please advise me?
Thanks