CookieContainer.Add Метод
Определение
Добавляет объект Cookie в CookieContainer.Adds a Cookie to a CookieContainer.
Перегрузки
Add(Cookie) |
Добавляет объект Cookie в CookieContainer.Adds a Cookie to a CookieContainer. В этом методе используется домен из класса Cookie для определения доменной коллекции, которую требуется связать с Cookie.This method uses the domain from the Cookie to determine which domain collection to associate the Cookie with. |
Add(CookieCollection) |
Добавляет содержимое CookieCollection в CookieContainer.Adds the contents of a CookieCollection to the CookieContainer. |
Add(Uri, Cookie) |
Добавляет экземпляр Cookie в CookieContainer для определенного URI.Adds a Cookie to the CookieContainer for a particular URI. |
Add(Uri, CookieCollection) |
Добавляет содержимое CookieCollection в CookieContainer для определенного URI.Adds the contents of a CookieCollection to the CookieContainer for a particular URI. |
Add(Cookie)
Добавляет объект Cookie в CookieContainer.Adds a Cookie to a CookieContainer. В этом методе используется домен из класса Cookie для определения доменной коллекции, которую требуется связать с Cookie.This method uses the domain from the Cookie to determine which domain collection to associate the Cookie with.
public:
void Add(System::Net::Cookie ^ cookie);
public void Add (System.Net.Cookie cookie);
member this.Add : System.Net.Cookie -> unit
Параметры
- cookie
- Cookie
Действие Cookie, добавляемое в коллекцию CookieContainer.The Cookie to be added to the CookieContainer.
Исключения
Свойство cookie
имеет значение null
.cookie
is null
.
Домен для cookie
является null
или пустой строкой ("").The domain for cookie
is null
or the empty string ("").
Значение cookie
больше, чем значение maxCookieSize
cookie
is larger than maxCookieSize
.
- или --or-
домен для cookie
не является допустимым URI.the domain for cookie
is not a valid URI.
Комментарии
Если свойство равно или Capacity превышает свойство, то перед добавлением cookie
параметра Cookie один или несколько экземпляров удаляются из контейнера. CountIf the Count property equals or exceeds the Capacity property, one or more Cookie instances are removed from the container before adding the cookie
parameter. Будет удалено достаточное количество Cookie экземпляров Capacity для приведения ниже:Есливзаданнойобластиестьэкземплярысистекшимсрокомдействия,онибудуточищены.CountEnough Cookie instances are removed to bring Count below Capacity as follows: if there are expired instances in the given scope, they are cleaned up. Если нет, то наименее недавно CookieCollection использованный объект будет найден и удален из контейнера.If not, then the least recently used CookieCollection is found and removed from the container.
Дополнительно
Add(CookieCollection)
Добавляет содержимое CookieCollection в CookieContainer.Adds the contents of a CookieCollection to the CookieContainer.
public:
void Add(System::Net::CookieCollection ^ cookies);
public void Add (System.Net.CookieCollection cookies);
member this.Add : System.Net.CookieCollection -> unit
Public Sub Add (cookies As CookieCollection)
Параметры
- cookies
- CookieCollection
Действие CookieCollection, добавляемое в коллекцию CookieContainer.The CookieCollection to be added to the CookieContainer.
Исключения
Свойство cookies
имеет значение null
.cookies
is null
.
Комментарии
Если свойство равно свойству, то перед добавлением Cookie содержимого cookies
параметра один или несколько экземпляров удаляются из контейнера. Capacity CountIf the Count property equals the Capacity property, one or more Cookie instances are removed from the container before adding the contents of the cookies
parameter. Будет Cookie удалено достаточное количество экземпляров, cookies
чтобы освободить место для следующего: при наличии просроченных экземпляров они очищаются.Enough Cookie instances are removed to make room for cookies
as follows: if there are expired instances, they are cleaned up. Если это не так или если требуется больше места, наименее недавно использованный CookieCollection объект будет найден и удален из контейнера.If not, or if more room is needed, then the least recently used CookieCollection is found and removed from the container.
Дополнительно
Add(Uri, Cookie)
Добавляет экземпляр Cookie в CookieContainer для определенного URI.Adds a Cookie to the CookieContainer for a particular URI.
public:
void Add(Uri ^ uri, System::Net::Cookie ^ cookie);
public void Add (Uri uri, System.Net.Cookie cookie);
member this.Add : Uri * System.Net.Cookie -> unit
Параметры
- uri
- Uri
URI объекта Cookie, добавляемого в CookieContainer.The URI of the Cookie to be added to the CookieContainer.
- cookie
- Cookie
Действие Cookie, добавляемое в коллекцию CookieContainer.The Cookie to be added to the CookieContainer.
Исключения
Значение параметра uri
— null
, или значение параметра cookie
— null
.uri
is null
or cookie
is null
.
Значение cookie
больше, чем значение maxCookieSize
cookie
is larger than maxCookieSize
.
-или--or-
Домен для cookie
не является допустимым URI.The domain for cookie
is not a valid URI.
Комментарии
При добавлении Cookie экземпляра только для одного конкретного узла не Domain задавайте свойство Cookie экземпляра.If you add a Cookie instance for just one specific host, do not set the Domain property of the Cookie instance. Это значение задается автоматически на основе универсального кода ресурса (URI).This is set automatically, based on the URI.
Если URI соответствует локальному домену и отправляется всем узлам в локальном домене, установите Cookie Domain свойство равным ". local".If your URI corresponds to your local domain and sends to all the hosts on the local domain, set the CookieDomain property equal to ".local". В противном случае убедитесь, что оно совпадает с именем узла, используемым в URI.Otherwise, make sure it matches the host name used in the URI.
Если свойство объекта имеет значение Path NetscapeCookie, свойство объекта, если оно не задано явно, является производным от URI и представляет собой полный путь из URI, включая имя страницы. Cookie VersionIf the Version property of a Cookie is Netscape, the Path property of the Cookie, if not set explicitly, is derived from the URI and is the complete path from the URI, including the page name.
Если свойство равно свойству, то перед cookie
добавлением Cookie параметра один или несколько экземпляров удаляются из контейнера. Capacity CountIf the Count property equals the Capacity property, one or more Cookie instances are removed from the container before adding the cookie
parameter. Будет удалено достаточное количество Cookie экземпляров Capacity для приведения ниже:Есливобластиестьэкземплярысистекшимсрокомдействия,ониочищаются.CountEnough Cookie instances are removed to bring Count below Capacity as follows: if there are expired instances in scope, they are cleaned up. Если нет, то наименее недавно CookieCollection использованный объект будет найден и удален из контейнера.If not, then the least recently used CookieCollection is found and removed from the container.
Дополнительно
Add(Uri, CookieCollection)
Добавляет содержимое CookieCollection в CookieContainer для определенного URI.Adds the contents of a CookieCollection to the CookieContainer for a particular URI.
public:
void Add(Uri ^ uri, System::Net::CookieCollection ^ cookies);
public void Add (Uri uri, System.Net.CookieCollection cookies);
member this.Add : Uri * System.Net.CookieCollection -> unit
Параметры
- uri
- Uri
URI объекта CookieCollection, добавляемого в CookieContainer.The URI of the CookieCollection to be added to the CookieContainer.
- cookies
- CookieCollection
Действие CookieCollection, добавляемое в коллекцию CookieContainer.The CookieCollection to be added to the CookieContainer.
Исключения
cookies
— null
.cookies
is null
.
Домен для одного из файлов cookie в cookies
указан как null
.The domain for one of the cookies in cookies
is null
.
Один из файлов cookie в cookies
содержит недопустимый домен.One of the cookies in cookies
contains an invalid domain.
Комментарии
При добавлении Cookie экземпляра только для одного конкретного узла не Domain задавайте свойство Cookie экземпляра.If you add a Cookie instance for just one specific host, do not set the Domain property of the Cookie instance. Это значение задается автоматически на основе универсального кода ресурса (URI).This is set automatically, based on the URI.
Если URI соответствует локальному домену и отправляется всем узлам в локальном домене, установите Cookie Domain свойство равным ". local".If your URI corresponds to your local domain and sends to all the hosts on the local domain, set the CookieDomain property equal to ".local". В противном случае убедитесь, что оно совпадает с именем узла, используемым в URI.Otherwise, make sure it matches the host name used in the URI.
Если Count значение Capacityравно, то один Cookie или несколько экземпляров удаляются из контейнера перед добавлением cookie
параметра.If Count equals Capacity, one or more Cookie instances is removed from the container before adding the cookie
parameter. Будет удалено достаточное количество Cookie экземпляров Capacity для приведения ниже:Есливобластидействиябылиочищеныэкземплярысистекшимсрокомдействия,онибудутудалены.CountEnough Cookie instances are removed to bring Count below Capacity as follows: if there are expired instances in scope they are cleaned up. Если нет, то наименее недавно CookieCollection использованный объект будет найден и удален из контейнера.If not, then the least recently used CookieCollection is found and removed from the container.