What is the difference between building CookieContainer and Response.Cookies?

I did some research on this, and I could not find a direct answer.

Are there cookies in the container that I cannot use for the Response.Cookies collection? How are cookies handled between requests using these objects? Some cookies are stored in the container, but not others?

+6
source share
1 answer

Judging by the tags you used on this question, it looks like you are confused.

CookieContainer and CookieCollection are used with HttpWebRequest when your program is an HTTP client. CookieCollection stores cookies associated with a single domain name. CookieContainer stores all cookies on top of all domain names.

ASP.NET HttpRequest.Cookies has an HttpCookieCollection and is used when your program is an HTTP server. It stores cookies sent by the client to the server. Since there is only one domain name (i.e. yours), there is no need for a two-dimensional collection.

Two sets of classes ( CookieContainer and CookieCollection vs HttpCookieCollection ) are completely unrelated to each other.

In this post, I provided some basic background for the cookie collection classes in .NET, but I don't understand your question. What are you trying to do?

+8
source

Source: https://habr.com/ru/post/926256/


All Articles