Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to take a backup of sitecollection whenever user tried to delete it. I am using SiteDeleting(SPWebEventProperties properties) event for this. One constraint is, i need to cancel the delete if the user is not siteadmin. My question is, how to cancel the delete if the user is not site admin.

bool res = properties.Web.UserIsSiteAdmin();            
          if (res)

i have already done with the backup part but need to know how to cancel the delete.

Thanks in advance!

share|improve this question

1 Answer 1

In your SPWebEventProperties you have a Cancel and an ErrorMessage property that you can use to cancel the event.

    properties.Cancel = true; // setting this will change Status property from Continue to Cancel-WithError
    properties.ErrorMessage = "You are not allowed to delete this site";


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.