SPWebApplicationBuilder Class
Windows SharePoint Services 3
Creates an SPWebApplication object, providing default settings for all the required values and allowing the caller to change only those properties that need values that are different from the default.
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
The following example uses the SPWebApplicationBuilder to create a new SharePoint Web application on port 999. The example creates and provisions a Web application, and then it creates a new site collection and top-level site at the root.
SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder(SPFarm.Local); int myPort = 999; webAppBuilder.Port = myPort; SPWebApplication newApplication = webAppBuilder.Create(); newApplication.Provision(); SPSite mySiteCollection = newApplication.Sites.Add("/", "DOMAIN\\UserAlias", "user@microsoft.com"); mySiteCollection.Close();