2012-07-22 44 views
1

好的,現在我已經調查了代碼,當存儲cookie集合在CookieContainer中沒有任何cookie可用時,所以我想轉移並使用標題。唯一的問題是我不明白如何使用它們,以便我可以從網站上下載文件。HTTPS問題與Cookie C#

有人可以給我一個我將如何使用頭的例子嗎?

而且我用的餅乾的代碼如下,也許是一個錯誤:

 HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 
     CookieContainer newCookies = new CookieContainer(); 
     newCookies.Add(response.Cookies); 

我得到的是這樣的標題Headers = {Content-Length: 6292 Cache-Control: private Content-Type: text/html; charset=utf-8 Date: Sun, 22 Jul 2012 03:12:59 GMT Set-Cookie: ASP.NET_SessionId=dpub2i550ynjfonuv0o0n4nb; domain=website.co.nz; path=/; HttpOnly Server: Microsoft-IIS/6.0 X-AspNet-Vers...

代碼不會拋出異常。正如我不使用request.Method = "GET";

回答

0

這是在調試器中查看變量時調用的.ToString()方法的結果。您需要訪問CookieContainer的成員。

+0

現在我覺得自己很蠢,但是能詳細說明'.ToString()'的位置嗎?在'響應.Cookies'結尾?或在'.GetResponse()'的末尾。我對'.GetResponse()'下注,但我不確定,我會放棄並讓你知道。謝謝! – 2012-07-22 06:33:10