Delete(String) Method

The Delete method of the SPSiteCollection class deletes the SPSite object with the specified server-relative URL from the collection.


strSiteUrl A string that contains the server-relative URL of the site object to delete (for example, Site_Name or sites/Site_Name).


To delete a site collection from a virtual server requires security validation that uses the AdminFormDigest property of the SPGlobalAdmin class to insert a message digest on the page in the browser. This can be done by registering the digest as a hidden field through the RegisterHiddenField method of the System.Web.UI.Page class. In addition, use the RequestFromAdminPort field of the SPGlobalAdmin class to specify that the context of the request is through the administrative port.


The following code example deletes a top-level site from the site collection of a specified virtual server.


Platforms: Microsoft Windows Server 2003

Security: Code Access Security