<baseAddressPrefixFilters><baseAddressPrefixFilters>

表示的組態項目會指定通過篩選條件,提供一個機制,裝載在 IIS 中的 Windows Communication Foundation (WCF) 應用程式時挑選適當的網際網路資訊服務 (IIS) 繫結的集合。Represents a collection of configuration elements that specify pass through filters, which provide a mechanism to pick the appropriate Internet Information Services (IIS) bindings when hosting the Windows Communication Foundation (WCF) application in IIS.

警告

<baseAddressPrefixFilters > 無法辨識"localhost",請改用完整的電腦名稱。<baseAddressPrefixFilters> does not recognize "localhost", use the fully qualified machine name instead.

<system.ServiceModel><system.ServiceModel>
<ServiceHostingEnvironment ><ServiceHostingEnvironment>

語法Syntax

<serviceHostingEnvironment>  
     <baseAddressPrefixFilters>  
        <add prefix="string"/>  
     </baseAddressPrefixFilters>  
</serviceHostingEnvironment>  

屬性和項目Attributes and Elements

下列各節描述屬性、子項目和父項目。The following sections describe attributes, child elements, and parent elements.

屬性Attributes

無。None.

子項目Child Elements

項目Element 描述Description
<add><add> 新增組態項目,這個項目會指定由服務主機使用之基底位址的前置詞篩選條件。Adds a configuration element that specifies a prefix filter for the base addresses used by the service host.

父項目Parent Elements

項目Element 描述Description
<serviceHostingEnvironment ><serviceHostingEnvironment> 定義服務裝載環境為特定傳輸產生的類型。Defines the type the service hosting environment instantiates for a particular transport.

備註Remarks

前置詞篩選條件為共用裝載提供者提供一種方式,使其可指定服務所要使用的 URI。A prefix filter provides a way for shared hosting providers to specify which URIs are to be used by the service. 它可讓共用主機在同一個網站上裝載多個應用程式,而且同一個配置中可以有不同的基底位址。It enables shared hosts to host multiple applications with different base addresses for the same scheme on the same site.

IIS 網站是包含虛擬目錄的虛擬應用程式的容器 (Container)。IIS Web sites are containers for virtual applications which contain virtual directories. 網站中的應用程式則可以透過一個或多個 IIS 繫結來存取。The application in a site can be accessed through one or more IIS bindings. IIS 繫結提供繫結通訊協定和繫結這兩項資訊。IIS bindings provide two pieces of information: binding protocol and binding information. 繫結通訊協定 (例如 HTTP) 會定義產生通訊的配置,而繫結資訊 (例如 IPAddress、Port、Hostheader) 包含用來存取該網站的資料。Binding protocol (for example, HTTP) defines the scheme over which communication occurs, and binding information (for example, IP Address, Port, Hostheader) contains data used to access the site.

IIS 支援為每個網站指定多個 IIS 繫結,讓每個配置都有多個基底位址。IIS supports specifying multiple IIS bindings for each site, which results in multiple base addresses for each scheme. 因為在網站下裝載的 WCF 服務允許每個配置繫結至一個基底位址,所以您可以使用前置詞篩選功能挑選裝載服務所需的基底位址。Because a WCF service hosted under a site allows binding to only one base address for each scheme, you can use the prefix filter feature to pick the required base address of the hosted service. IIS 提供的傳入基底位址會依據選擇性的前置詞清單篩選條件進行篩選。The incoming base addresses, supplied by IIS, are filtered based on the optional prefix list filter.

例如,您的網站可能包含下列基底位址。For example, your site can contain the following base addresses.

http://testl.fabrikam.com/Service.svc  
http://test2.fabrikam.com/Service.svc  

您可以使用下列組態檔在 appdomain 層級指定前置詞篩選條件。You can use the following configuration file to specify a prefix filter at the appdomain level.

<system.serviceModel>  
  <serviceHostingEnvironment>  
     <baseAddressPrefixFilters>  
        <add prefix="net.tcp://test1.fabrikam.com:8000"/>  
        <add prefix="http://test2.fabrikam.com:9000"/>  
    </baseAddressPrefixFilters>  
  </serviceHostingEnvironment>  
</system.serviceModel>  

在此範例中,net.tcp://test1.fabrikam.com:8000http://test2.fabrikam.com:9000 分別是其配置的唯一基底位址,而且已被允許通過篩選。In this example, net.tcp://test1.fabrikam.com:8000 and http://test2.fabrikam.com:9000 are the only base addresses for their respective schemes, which are allowed to be passed through.

根據預設,如果沒有指定前置詞,則所有位址都會通過。By default, when prefix is not specified, all addresses are passed through. 如果指定前置詞,則只會允許要通過之配置的相符基底位址。Specifying the prefix only allows the matching base address for that scheme to be passed through.

注意

篩選條件不支援任何萬用字元。The filter does not support any wildcards. 此外,IIS 提供的 baseAddress 中,可能會有位址繫結至不在 baseAddressPrefixFilters 清單中的配置,In addition, the baseAddresses supplied by IIS may have addresses bound to other schemes not present in the baseAddressPrefixFilters list. 而且這些位址尚未經過篩選。These addresses are not filtered out.

另請參閱See Also

BaseAddressPrefixFilterElementCollection
ServiceHostingEnvironmentSection
ServiceHostingEnvironment
裝載Hosting