CookieContainer.GetCookieHeader(Uri) 方法

定义

获取 HTTP Cookie 标头,该标头包含表示与特定 URI 关联的 Cookie 实例的 HTTP Cookie。Gets the HTTP cookie header that contains the HTTP cookies that represent the Cookie instances that are associated with a specific URI.

public:
 System::String ^ GetCookieHeader(Uri ^ uri);
public string GetCookieHeader (Uri uri);
member this.GetCookieHeader : Uri -> string
Public Function GetCookieHeader (uri As Uri) As String

参数

uri
Uri

所需的 Cookie 实例的 URI。The URI of the Cookie instances desired.

返回

一个 HTTP Cookie 标头,其中包含表示由分号分隔的 Cookie 实例的字符串。An HTTP cookie header, with strings representing Cookie instances delimited by semicolons.

例外

urinulluri is null.

注解

GetCookieHeader 返回一个字符串,该字符串保存 uri指定的 Cookie 实例的 HTTP cookie 标头。GetCookieHeader returns a string that holds the HTTP cookie header for the Cookie instances specified by uri. 通过添加与 uri关联的每个 Cookie 的字符串表示形式来生成 HTTP 标头。The HTTP header is built by adding a string representation of each Cookie associated with uri. 请注意,字符串的确切格式取决于 Cookie 遵循的 RFC。Note that the exact format of the string depends on the RFC that the Cookie conforms to. uri 关联的所有 Cookie 实例的字符串都由分号组合和分隔。The strings for all the Cookie instances that are associated with uri are combined and delimited by semicolons.

此字符串的格式不正确,无法用作 SetCookies 方法的第二个参数。This string is not in the correct format for use as the second parameter of the SetCookies method.

适用于

另请参阅