HttpWebRequest-resp.Headers["Set-Cookie"] ist null

Update 1:
Screenshot von post/get-Header: http://imageshack.us/photo/my-images/826/getpost.png

Ich bin auf der Suche nach Hilfe bei einer web-Anfrage. Der Zweck des Antrags ist es, sich bei einer Website anmelden, und rufen Sie die Set-Cookie-header. Ich bin dankbar für jede Hilfe!!!

Ich versuche, um sich bei einer Website anmelden und abrufen der cookie-Wert mit dem code unten. Jedoch, die Set-Cookie-header ist immer null:

static void Main(string[] args)
{
    string formUrl = "https://account.guildwars2.com/login";
    string formParams = string.Format("email={0}&password={1}", "xxx", "xxx");
    string cookieHeader;
    var req = (HttpWebRequest)WebRequest.Create(formUrl);
    req.Referer = "https://account.guildwars2.com/login";
    req.ContentType = "application/x-www-form-urlencoded";
    req.Method = "POST";
    req.KeepAlive = true;
    byte[] bytes = Encoding.ASCII.GetBytes(formParams);
    req.ContentLength = bytes.Length;
    using (Stream os = req.GetRequestStream())
    {
        os.Write(bytes, 0, bytes.Length);
    }
    WebResponse resp = req.GetResponse();
    cookieHeader = resp.Headers["Set-Cookie"];
}

Ich bin mir nicht sicher, ob dies hat nichts zu tun mit Umleitungen, weil in der C# - Anwendung, die Antwort-uri "https://account.guildwars2.com/login?redirect_uri=/download"

Antwort-Header Chrome

  • Content-Length:0
  • Content-Type:text/html
  • Datum:Sat, 29 Sep 2012 15:07:30 GMT
  • Lage:download
  • Server:Microsoft-IIS/7.5
  • Set-Cookie:s=60B845F0-4E22-4A4B-890B-F3B885CEF9AE; Domain=guildwars2.com; Path=/; Version=1
  • X-Powered-By:ARR/2.5

Antwort von C# - Anwendung

  • Content-Length: 7344
  • Content-Type: text/html
  • Datum: Sat, 29 Sep 2012 15:42:44 GMT
  • Server: Microsoft-IIS/7.5
  • X-Powered-By: ARR/2.5
  • Ich denke, Sie müssen httpWebRequest.CookieCollection neue CookieCollection vor dem senden, vielleicht haben misstyped, die nicht mit VS atm.
  • Ich habe versucht, req.CookieContainer = new CookieContainer(); aber nichts wird Hinzugefügt
InformationsquelleAutor Skalis | 2012-09-29
Schreibe einen Kommentar