ApplicationDefaults.ApplicationPoolName Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the application pool that is assigned by default to all applications under the current Web site.
public:
property System::String ^ ApplicationPoolName { System::String ^ get(); void set(System::String ^ value); };
public string ApplicationPoolName { get; set; }
member this.ApplicationPoolName : string with get, set
Public Property ApplicationPoolName As String
Property Value
The name of the application pool that all applications under the current Site are assigned to by default. The default is "DefaultAppPool".
Examples
The following example displays the default application values for each site.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;
namespace AdministrationSnippets
{
public class AdministrationApplicationDefaults
{
// Displays the default application values for all configured sites.
public void GetApplicationDefaults()
{
ServerManager manager = new ServerManager();
foreach (Site s in manager.Sites)
{
ApplicationDefaults d = s.ApplicationDefaults;
Console.WriteLine("Site: {0}", s.Name);
Console.WriteLine(" |--Default Application Pool: {0}",
d.ApplicationPoolName);
Console.WriteLine(" +--Default Protocols Enabled: {0}\r\n",
d.EnabledProtocols);
}
}
}
}
The following example sets the default values for applications created under the default Web site, creates a new application, and then verifies that the application properties are set to the default values.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;
namespace AdministrationSnippets
{
public class AdministrationApplicationDefaults
{
// Sets the default values for applications configured under the
// default Web site.
public void SetApplicationDefaults()
{
ServerManager manager = new ServerManager();
Site defaultSite = manager.Sites["Default Web Site"];
ApplicationDefaults defaultVals = defaultSite.ApplicationDefaults;
// Set the application defaults.
defaultVals.ApplicationPoolName = "CommunitySites";
defaultVals.EnabledProtocols = "http";
// Create a new application.
defaultSite.Applications.Add(
"/discussion", @"C:\inetpub\wwwroot\forums");
manager.CommitChanges();
// Read the application's values.
Application discussion = defaultSite.Applications["/discussion"];
Console.WriteLine("Site: {0}", defaultSite.Name);
Console.WriteLine(" |--Default Application Pool: {0}",
discussion.ApplicationPoolName);
Console.WriteLine(" +--Default Protocols Enabled: {0}\r\n",
discussion.EnabledProtocols);
}
}
}
Remarks
If an application pool is not explicitly set for an application, the Microsoft.Web.Administration.Application.ApplicationPoolName property returns the value configured by this property.