I am using the following code to programatically create a
web application & sub site,
try
{
SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder(SPFarm.Local);
SPWebApplication newApplication;
int myPort = 3333;
webAppBuilder.Port = myPort; //Port No.
webAppBuilder.RootDirectory = new System.IO.DirectoryInfo("C:\\Inetpub\\wwwroot\\wss\\VirtualDirectories\\" + myPort);
webAppBuilder.CreateNewDatabase = true; // Create new database
webAppBuilder.DatabaseName = "WSS_Content_372772890a5a4a04abb460cd9ea3bd22"; // Database name
webAppBuilder.DatabaseServer = webAppBuilder.DefaultZoneUri.Host; // DatabaseServer Host name/computer name
webAppBuilder.UseNTLMExclusively = true; // Use NTLM authentication
newApplication = webAppBuilder.Create(); // Create new
web application
newApplication.Provision(); // Provision it into
web farm
using (var mySiteCollection = newApplication.Sites.Add("/", "Site 3", "Site 3 Decscription", 1033, "STS#1", "In-Wai-Svr2\\Administrator", "Administrator", "
[email protected]"))
{
using (var rootWeb = mySiteCollection.RootWeb)
{
// Code customizing root site goes here
using (var subSite = rootWeb.Webs.Add("Site3.1", "Site 3.1", "Site 3.1 Description", 1033, "STS#1", true, false))
{
// Code customizing sub site goes here
}
}
}
}
catch(Exception ex)
{
;
}
It works fine i.e. it creates the
web application on the specified port with sub site but this sub site will not be shown under Sites menu of Quick launch bar also it will not be shown as a separate tab on the Home Page. Is it possible to do it programatically?