概要
<application> 要素の <add>
要素は、親アプリケーションに追加の依存関係を追加します。
互換性
バージョン | メモ |
---|---|
IIS 10.0 | <add> 要素は IIS 10.0 では変更されませんでした。 |
IIS 8.5 | <add> 要素は IIS 8.5 では変更されませんでした。 |
IIS 8.0 | <add> 要素は IIS 8.0 では変更されませんでした。 |
IIS 7.5 | <add> 要素は IIS 7.5 では変更されませんでした。 |
IIS 7.0 | <application> 要素の <add> 要素が IIS 7.0 で導入されました。 |
IIS 6.0 | <applicationDependencies> 要素は、IIsWebService メタベース オブジェクトの IIS 6.0 ApplicationDependencies 属性を置き換えます。 |
段取り
<application>
要素の <add>
要素は、IIS 7 の既定のインストールに含まれています。
操作方法
IIS 7 の <applicationDependencies>
要素を構成するためのユーザー インターフェイスはありません。 <applicationDependencies>
要素をプログラムで構成する方法の例については、このドキュメントのコード サンプルのセクションを参照してください。
構成
属性
属性 | 説明 |
---|---|
groupID |
必須の文字列属性です。 親アプリケーションに関連付けられている追加の groupID を指定します。 |
子要素
なし。
構成サンプル
次の構成サンプルは、Active Server Pages (ASP) とカスタム アプリケーションを IIS 7 にインストールした後の、既定の Web サイトの <applicationDependencies>
要素内のアプリケーションの依存関係と <isapiCgiRestriction>
内の関連エントリを示しています。
- Active Server Pages アプリケーションは、"ASP" ISAPI/CGI 制限グループに依存しています。
- カスタム アプリケーションには、"MyCustomGroup" ISAPI/CGI 制限グループへの依存関係と、ASP ISAPI/CGI 制限グループへの追加の依存関係があります。
<system.webServer>
<security>
<isapiCgiRestriction notListedIsapisAllowed="false" notListedCgisAllowed="false">
<clear />
<add allowed="true" groupId="ASP"
path="C:\Windows\system32\inetsrv\asp.dll"
description="Active Server Pages" />
<add allowed="true" groupId="MyCustomGroup"
path="C:\Windows\system32\inetsrv\mycustom.dll"
description="My Custom Application" />
</isapiCgiRestriction>
</security>
</system.webServer>
<___location path="Default Web Site">
<system.webServer>
<security>
<applicationDependencies>
<application name="My Custom Application" groupId="MyCustomGroup">
<add groupId="ASP" />
</application>
</applicationDependencies>
</security>
</system.webServer>
</___location>
サンプル コード
次の構成サンプルは、既定の Web サイトの <applicationDependencies>
要素内のアプリケーションの依存関係を示しています。 カスタム アプリケーションには、"MyCustomGroup" ISAPI/CGI 制限グループへの依存関係と、ASP ISAPI/CGI 制限グループへの追加の依存関係があります。
AppCmd.exe
appcmd.exe set config "Default Web Site" -section:system.webServer/security/applicationDependencies /+"[name='My Custom Application',groupId='MyCustomGroup']" /commit:apphost
appcmd.exe set config "Default Web Site" -section:system.webServer/security/applicationDependencies /+"[name='My Custom Application',groupId='MyCustomGroup'].[groupId='ASP']" /commit:apphost
Note
AppCmd.exe を使用してこれらの設定を構成するときは、commit パラメーターを必ず apphost
に設定する必要があります。 これで、ApplicationHost.config ファイルの適切な場所セクションに構成設定がコミットされます。
C#
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample
{
private static void Main()
{
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection applicationDependenciesSection = config.GetSection("system.webServer/security/applicationDependencies", "Default Web Site");
ConfigurationElementCollection applicationDependenciesCollection = applicationDependenciesSection.GetCollection();
ConfigurationElement applicationElement = applicationDependenciesCollection.CreateElement("application");
applicationElement["name"] = @"My Custom Application";
applicationElement["groupId"] = @"MyCustomGroup";
ConfigurationElementCollection applicationCollection = applicationElement.GetCollection();
ConfigurationElement addElement = applicationCollection.CreateElement("add");
addElement["groupId"] = @"ASP";
applicationCollection.Add(addElement);
applicationDependenciesCollection.Add(applicationElement);
serverManager.CommitChanges();
}
}
}
VB.NET
Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim applicationDependenciesSection As ConfigurationSection = config.GetSection("system.webServer/security/applicationDependencies", "Default Web Site")
Dim applicationDependenciesCollection As ConfigurationElementCollection = applicationDependenciesSection.GetCollection
Dim applicationElement As ConfigurationElement = applicationDependenciesCollection.CreateElement("application")
applicationElement("name") = "My Custom Application"
applicationElement("groupId") = "MyCustomGroup"
Dim applicationCollection As ConfigurationElementCollection = applicationElement.GetCollection
Dim addElement As ConfigurationElement = applicationCollection.CreateElement("add")
addElement("groupId") = "ASP"
applicationCollection.Add(addElement)
applicationDependenciesCollection.Add(applicationElement)
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var applicationDependenciesSection = adminManager.GetAdminSection("system.webServer/security/applicationDependencies", "MACHINE/WEBROOT/APPHOST/Default Web Site");
var applicationDependenciesCollection = applicationDependenciesSection.Collection;
var applicationElement = applicationDependenciesCollection.CreateNewElement("application");
applicationElement.Properties.Item("name").Value = "My Custom Application";
applicationElement.Properties.Item("groupId").Value = "MyCustomGroup";
var applicationCollection = applicationElement.Collection;
var addElement = applicationCollection.CreateNewElement("add");
addElement.Properties.Item("groupId").Value = "ASP";
applicationCollection.AddElement(addElement);
applicationDependenciesCollection.AddElement(applicationElement);
adminManager.CommitChanges();
VBScript
Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set applicationDependenciesSection = adminManager.GetAdminSection("system.webServer/security/applicationDependencies", "MACHINE/WEBROOT/APPHOST/Default Web Site")
Set applicationDependenciesCollection = applicationDependenciesSection.Collection
Set applicationElement = applicationDependenciesCollection.CreateNewElement("application")
applicationElement.Properties.Item("name").Value = "My Custom Application"
applicationElement.Properties.Item("groupId").Value = "MyCustomGroup"
Set applicationCollection = applicationElement.Collection
Set addElement = applicationCollection.CreateNewElement("add")
addElement.Properties.Item("groupId").Value = "ASP"
applicationCollection.AddElement(addElement)
applicationDependenciesCollection.AddElement(applicationElement)
adminManager.CommitChanges()