Go back to index
How to create web application
Following code block explains how to programmatically create a web application in Sharepoint Farm.
using System;
using SPTool.Library;
using System.Collections.ObjectModel;
namespace SPTool.Test
{
class Program
{
static void Main(string[] args)
{
SPTFarm farm = new SPTFarm();
// Create web application
SPTReturn returnObj = farm.CreateWebApplication("SPTool Webapplication", 80, "", @"C:\inetpub\wwwroot\wss\VirtualDirectories\80",
true, false, false, new Uri("http://sptool/"), "SPTool Application Pool", @"domain\username", "password",
"SPTool-Server", "SPTool-Database", "", "");
// Check the status of web application creation
if (returnObj.State == SPTState.Success)
{
// Successfully created web application
}
else
{
// Creating web application failed
}
}
}
}
Go back to index