Share via


Application.ApplicationPoolName Property

Definition

Gets or sets the name of the application pool that the application is assigned to.

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 the application is assigned to.

Examples

The following example reads the configuration settings for an existing Application. The code displays the value returned from the ApplicationPoolName property for the applications configured under the "Default Web Site".

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;

namespace AdministrationSnippets
{
    public class AdministrationApplicationApplicationPoolName
    {
// Writes out the applications and the application pool names 
// associated with the applications under the default Web site.
public void GetApplicationPoolNames()
{
    ServerManager manager = new ServerManager();
    Site defaultSite = manager.Sites["Default Web Site"];

    foreach (Application app in defaultSite.Applications)
    {
        Console.WriteLine(
            "{0} is assigned to the '{1}' application pool.", 
            app.Path, app.ApplicationPoolName);
    }
}
    }
}

The following example creates a new ApplicationPool and then creates a new application that is assigned to the newly created ApplicationPool.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;

namespace AdministrationSnippets
{
    public class AdministrationApplicationApplicationPoolName
    {
// Creates a new application pool and a new application, then 
// assigns the application to the new application pool.
public void SetApplicationPoolName()
{
    ServerManager manager = new ServerManager();
    Site defaultSite = manager.Sites["Default Web Site"];

    ApplicationPool blogPool = 
        manager.ApplicationPools.Add("BlogApplicationPool");
    Application app = defaultSite.Applications.Add(
        "/blogs", @"C:\inetpub\wwwroot\blogs");
    app.ApplicationPoolName = blogPool.Name;
    manager.CommitChanges();
}
    }
}

Remarks

Each site can have a default application pool configured. If an application pool is not explicitly set for the application, the ApplicationPoolName property returns the default application pool name configured for the site. Use the Microsoft.Web.Administration.Site.ApplicationDefaults property to view the default settings for a site.

Applies to