C# Add Application to IIS Website code example

Example: create iis website programmatically c#

private static void CreateAppPool(string poolname,bool enable32bitOn64, ManagedPipelineMode mode,string runtimeVersion="v4.0")  
{  
    using (ServerManager serverManager = new ServerManager())  
    {  
        ApplicationPool newPool = serverManager.ApplicationPools.Add(poolname);  
        newPool.ManagedRuntimeVersion = runtimeVersion;  
        newPool.Enable32BitAppOnWin64 = true;  
        newPool.ManagedPipelineMode = mode;  
        serverManager.CommitChanges();  
    }  
}