日期:2014-05-18  浏览次数:20920 次

c# 取sessionid
WebBrowser web = new WebBrowser();
web.Navigate(url);
上面两行打开网址后该怎样取sessionid。
(取cookie也行,里面也保存了sessionid)

(我对网页操作不在行哦)是winform

------解决方案--------------------
CookieContainer myCookieContainer = new CookieContainer(); 
string cookieStr = webBrowser1.Document.Cookie; 
string[] cookstr = cookieStr.Split( '; '); 
foreach (string str in cookstr) 

 string[] cookieNameValue = str.Split('='); 
Cookie ck = new Cookie(cookieNameValue[0].Trim().ToString(), cookieNameValue[1].Trim().ToString()); 
ck.Domain = "";
myCookieContainer.Add(ck);