Application.ApplicationPoolName 属性

定义

获取或设置应用程序分配到的应用程序池的名称。

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

属性值

应用程序分配到的应用程序池的名称。

示例

以下示例读取现有 Application的配置设置。 代码显示从 ApplicationPoolName “默认网站” 下配置的应用程序的 属性返回的值。

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);
    }
}
    }
}

以下示例创建新的 , ApplicationPool 然后创建分配给新创建的 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();
}
    }
}

注解

每个站点都可以配置默认应用程序池。 如果未为应用程序显式设置应用程序池,则 ApplicationPoolName 属性将返回为站点配置的默认应用程序池名称。 Microsoft.Web.Administration.Site.ApplicationDefaults使用 属性查看站点的默认设置。

适用于