FtpWebRequest.ConnectionGroupName Property

Definition

Gets or sets the name of the connection group that contains the service point used to send the current request.

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

Property Value

A String value that contains a connection group name.

Exceptions

A new value was specified for this property for a request that is already in progress.

Examples

The following code example retrieves the value of this property.

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
);

Remarks

Connection groups associate a set of requests with a particular connection or set of connections. The connections in a connection group can be reused only by requests originating in the same application domain, when the credentials on the request are the same and the request specifies the connection group name. When a request does not specify a connection group name, any existing connection to the requested server that is not associated with a connection group can be used. When the credentials are not the same, the existing connection is closed and the new request must be reauthenticated.

Using connection groups can improve performance because this allows all of the requests for a user to reuse the connection authenticated with the user's credentials.

Changing the ConnectionGroupName property after calling the GetRequestStream, BeginGetRequestStream, GetResponse, or BeginGetResponse method causes an InvalidOperationException exception.

Applies to

See also