connectionManagement 的 <add> 元素 (網路設定)

將 IP 位址或 DNS 名稱加入連線管理清單中。

<configuration>
  <system.net>
    <connectionManagement>
      <add>

Syntax

<add
  address="address expression"
  maxconnection="integer"
/>  

屬性和項目

下列章節說明屬性、子元素和父元素。

屬性

Attribute 說明
address 描述 IP 位址或 DNS 名稱的字串。
maxconnection 允許連接到伺服器的連線數目上限。 如果未提供,預設值為 2。

子元素

無。

父項目

Element 說明
connectionManagement 指定連接至網路主機的連線數目上限。

備註

address 屬性的值應該是表示所有連線的星號,或是 <schema>://<idn_hostname>[:<port>] 格式的字串。

如果傳遞至任何 HTTP 應用程式開發介面的 URI 包含 Unicode,將會使用 DnsSafeHost 在內部轉換名稱,可能會傳回 punicode 字串 (行為取決於目前的 IDN 組態)。

組態檔

此項目可以用於應用程式組態檔或電腦組態檔 (Machine.config)。

範例

下列範例會設定一個應用程式,以使用四個連接至伺服器 www.contoso.com 的連線,以及兩個連接至所有其他伺服器的連線。

<configuration>  
  <system.net>  
    <connectionManagement>  
      <add address="http://www.contoso.com" maxconnection="4" />  
      <add address="*" maxconnection="2" />  
    </connectionManagement>  
  </system.net>  
</configuration>  

另請參閱