FtpWebRequest.ConnectionGroupName 属性

定义

获取或设置连接组的名称,该连接组包含用于发送当前请求的服务点。

public:
 virtual property System::String ^ ConnectionGroupName { System::String ^ get(); void set(System::String ^ value); };
public override string? ConnectionGroupName { get; set; }
public override string ConnectionGroupName { get; set; }
member this.ConnectionGroupName : string with get, set
Public Overrides Property ConnectionGroupName As String

属性值

包含连接组名称的 String 值。

例外

对于一个已在进行的请求为此属性指定了一个新值。

示例

下面的代码示例检索此属性的值。

IWebProxy^ proxy = request->Proxy;
if ( proxy )
{
   Console::WriteLine( "Proxy: {0}", proxy->GetProxy( request->RequestUri ) );
}
else
{
   Console::WriteLine( "Proxy: (none)" );
}

Console::WriteLine( "ConnectionGroup: {0}", request->ConnectionGroupName == nullptr ? "none" : request->ConnectionGroupName );
IWebProxy proxy = request.Proxy;
if (proxy != null)
{
    Console.WriteLine("Proxy: {0}", proxy.GetProxy(request.RequestUri));
}
else
{
    Console.WriteLine("Proxy: (none)");
}

Console.WriteLine("ConnectionGroup: {0}",
    request.ConnectionGroupName == null ? "none" : request.ConnectionGroupName
);

注解

连接组将一组请求与特定连接或一组连接相关联。 当请求上的凭据相同且请求指定连接组名称时,只能由源自同一应用程序域的请求重复使用连接组中的连接。 当请求未指定连接组名称时,可以使用与请求的服务器不与连接组关联的任何现有连接。 当凭据不同时,现有连接将关闭,并且必须重新对新请求进行身份验证。

使用连接组可以提高性能,因为这允许用户的所有请求重复使用使用用户凭据进行身份验证的连接。

调用 、、 或 方法后更改 ConnectionGroupName 属性会导致InvalidOperationException异常。BeginGetResponseGetResponseBeginGetRequestStreamGetRequestStream

适用于

另请参阅