Cookies vermisst



  • Hallo,

    mein Problem ist, dass ich keine Cookies bekomme, wenn ich mit HttpWebRequest.Method="POST" arbeite. Mit Ethereal sehe ich noch etwas von den Cookies :
    Set-Cookie: sessionid=BW590K2KRBA0EQGIRUE4BFW6T7K3IQ0A; expires=Thu, 09-Nov-2006 23:19:38 GMT; path=/
    Set-Cookie: bbuserid=deleted; expires=Tue, 09-Nov-2004 23:19:37 GMT; path=/
    Set-Cookie: bbpassword=bb6597f143a74b16483d48a30e2f9bc9; expires=Thu, 09-Nov-2006 23:19:38 GMT; path=/
    Ich kann es mir bislang nicht erklären. Evtl. kann ja jemand einen Fehler im Code finden :

    if (Cookies.Count==0) Cookies = new CookieCollection();
                HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(url);
                webreq.CookieContainer = new CookieContainer();
                foreach (Cookie sCookie in Cookies)
                    webreq.CookieContainer.Add(sCookie);
                webreq.Method = "POST";
                webreq.Timeout = 10000;
    
                webreq.ContentType = "application/x-www-form-urlencoded";
                Stream loPostData = webreq.GetRequestStream();
                this.oPostStream.WriteTo(loPostData);
                this.oPostStream.Close();
                this.oPostStream = null;
                this.oPostData.Close();
                this.oPostData = null;
                loPostData.Close();
    
                HttpWebResponse webres = (HttpWebResponse)webreq.GetResponse();
                Stream webstream = webres.GetResponseStream();
                Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
                StreamReader readstream = new StreamReader(webstream, encode);
                char[] buffer = new char[1025];
                int n = readstream.Read(buffer, 0, 1024);
                String answer = new String(buffer, 0, 1024);
                while (n > 0)
                {
                    n = readstream.Read(buffer, 0, 1024);
                    String ans = new String(buffer, 0, n);
                    answer += ans;
                }
                if (webres.Cookies.Count > 0)
                {
                    Cookies = webres.Cookies;
                }
                webstream.Close();
                return answer;
    


  • nach vielem hin und her und noch mehr tests habe ich jetzt festgestellt, dass die Cookies nicht im Response sondern im Request sind.
    Sollte ich vor lautern googlen blind geworden sein ?


Anmelden zum Antworten