應用程式相依性 < 應用程式Dependencies>
概觀
安全性 > 元素的 <元素會與isapiCgiRestriction > 元素一起運作, <以定義哪些應用程式相依于一或多個 CGI 或 ISAPI 延伸限制。 <applicationDependencies>
如果應用程式包含在這個專案中,則應用程式會相依于isapiCgiRestriction > 專案中的專案 (或多個專案) <。
相容性
版本 | 備註 |
---|---|
IIS 10.0 | 未在 IIS 10.0 中修改專案 <applicationDependencies> 。 |
IIS 8.5 | 未在 IIS 8.5 中修改專案 <applicationDependencies> 。 |
IIS 8.0 | 未在 IIS 8.0 中修改專案 <applicationDependencies> 。 |
IIS 7.5 | 未在 IIS 7.5 中修改專案 <applicationDependencies> 。 |
IIS 7.0 | 元素 <applicationDependencies> 的 <security> 元素是在 IIS 7.0 中引進。 |
IIS 6.0 | 元素 <applicationDependencies> 會取代IIsWebService Metabase 物件的 IIS 6.0 ApplicationDependencies屬性。 |
安裝程式
元素 <applicationDependencies>
包含在 IIS 7 的預設安裝中。
作法
沒有用於設定 <applicationDependencies>
IIS 7 元素的使用者介面。 For examples of how to configure the <applicationDependencies>
element programmatically, see the Code Samples section of this document.
組態
屬性
無。
子元素
元素 | 描述 |
---|---|
application |
選擇性項目。 指定具有 CGI 或 ISAPI 擴充功能限制相依性的應用程式。 |
clear |
選擇性項目。 從 applicationDependencies 集合中移除應用程式的所有參考。 |
組態範例
下列組態範例說明當您在 IIS 7 上安裝 Active Server Pages (ASP) 和自訂應用程式之後,預設網站 元素中的應用程式相依性 <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>
範例程式碼
下列組態範例說明預設網站元素中的 <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
注意
當您使用 AppCmd.exe 來設定這些設定時,請務必將 認可 參數 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()