HttpWebRequest.ConnectionGroupName 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置请求的连接组的名称。
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
属性值
该请求的连接组的名称。 默认值是 null
。
示例
下面的代码示例演示如何使用用户信息来形成连接组,假定变量 username
、 password
和 domain
是在调用此代码之前由应用程序设置的。
// Create a secure group name.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
SHA1Managed^ Sha1 = gcnew SHA1Managed;
array<Byte>^updHash = Sha1->ComputeHash( Encoding::UTF8->GetBytes( "usernamepassworddomain" ) );
String^ secureGroupName = Encoding::Default->GetString( updHash );
// Create a request for a specific URL.
WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" );
// Set the authentication credentials for the request.
myWebRequest->Credentials = gcnew NetworkCredential( "username","password","domain" );
myWebRequest->ConnectionGroupName = secureGroupName;
// Get the response.
WebResponse^ myWebResponse = myWebRequest->GetResponse();
// Insert the code that uses myWebResponse here.
// Close the response.
myWebResponse->Close();
// Create a secure group name.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
SHA1Managed Sha1 = new SHA1Managed();
Byte[] updHash = Sha1.ComputeHash(Encoding.UTF8.GetBytes("username" + "password" + "domain"));
String secureGroupName = Encoding.Default.GetString(updHash);
// Create a request for a specific URL.
WebRequest myWebRequest=WebRequest.Create("http://www.contoso.com");
// Set the authentication credentials for the request.
myWebRequest.Credentials = new NetworkCredential("username", "password", "domain");
myWebRequest.ConnectionGroupName = secureGroupName;
// Get the response.
WebResponse myWebResponse=myWebRequest.GetResponse();
// Insert the code that uses myWebResponse here.
// Close the response.
myWebResponse.Close();
' Create a secure group name.
' This example uses the SHA1 algorithm.
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
Dim Sha1 As New SHA1Managed()
Dim updHash As [Byte]() = Sha1.ComputeHash(Encoding.UTF8.GetBytes(("username" + "password" + "domain")))
Dim secureGroupName As [String] = Encoding.Default.GetString(updHash)
' Create a request for a specific URL.
Dim myWebRequest As WebRequest = WebRequest.Create("http://www.contoso.com")
' Set the authentication credentials for the request.
myWebRequest.Credentials = New NetworkCredential("username", "password", "domain")
myWebRequest.ConnectionGroupName = secureGroupName
' Get the response.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
' Insert the code that uses myWebResponse here.
' Close the response.
myWebResponse.Close()
注解
属性 ConnectionGroupName 使你能够将请求与连接组相关联。 当应用程序为不同的用户向一个服务器发出请求时,这非常有用,例如从数据库服务器检索客户信息的网站。
继承者说明
每个连接组为服务器创建其他连接。 这可能会导致超过该服务器的 属性设置 ConnectionLimit 的连接数。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈