The problem that had been bothering me for N days was finally solved. When I used .NET to write the collector, I encountered a problem that required login. At this time, I had to set COOKIE.
But no matter how I set it, it didn't work. Later, through sniffing the data, I found that the COOKIE I set was only half set. The container.SetCookies(uri, cookie) method only set the part before the semicolon. When I separated the COOKIE When I added them one by one, I found that everything was solved.
1 private static void SetCookies(string CookieHead,Uri uri,CookieContainer container)
2 {
3 if(CookieHead==null)
4 {
5 return;
6}
7 else
8 {
9 string [] Cookies=CookieHead.Split(";".ToCharArray());
10 foreach(string cookie in Cookies)
11 {
12 //Log.Write(cookie);
13 container.SetCookies(uri,cookie);
14}
15}
16
17
18 }
http://www.cnblogs.com/Cricket1986/archive/2006/08/29/489869.html