title: HttpWebRequest (post) and redirection
body: <p>I'm trying to log onto the following website using HttpWebRequest: <a href="http://mostanmeldung.moessinger.at/login.php" rel="nofollow">http://mostanmeldung.moessinger.at/login.php</a></p>
  
  <p>Texts are in German, but they don't really matter. If you look at the source code (which by the way was not written by me, so don't blame me for its bad style :P), you will see a form tag that contains two input tags. The name of the first one is "BN" (username), and the name of the second one is "PW" (password). I am trying to send data containing values for these two inputs to the webserver using the HttpWebRequest class. However, posting the values redirects the request to another page called "einloggen.php". On that site I am told whether my login was successful.</p>
  
  <p>My problem is that I am able to send the data without any problems, however, all I receive is the content of "login.php", the site you have to enter your username and password on.</p>
  
  <p>This is what  my code looks like:</p>
  
  <pre><code>string post = String.Format(PostPattern, Username, Password);
  byte[] postBytes = Encoding.ASCII.GetBytes(post);
  
  CookieContainer cookies = new CookieContainer();
  
  // "Address": http://mostanmeldung.moessinger.at/login.php
  
  HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Address);
  req.CookieContainer = cookies;
  req.Method = "POST";
  req.ContentType = "application/x-www-form-urlencoded";
  req.ContentLength = postBytes.Length;
  req.AllowAutoRedirect = true;
  
  MessageBox.Show(post); // shows me "BN=boop;PW=hi"
  
  Stream reqStream = req.GetRequestStream();
  reqStream.Write(postBytes, 0, postBytes.Length);
  reqStream.Close();
  
  WebResponse res;
  if (/*req.HaveResponse &amp;&amp;*/ (res = req.GetResponse()) != null)
  {
      StreamReader reader = new StreamReader(res.GetResponseStream());
      MessageBox.Show(reader.ReadToEnd());
      return AuthResult.Success;
  }
  
  return AuthResult.NoResponse;
  </code></pre>
  
  <p>The message box at line 22 (5 lines before the end) shows me the content of "login.php" instead of "einloggen.php" which I am redirected to. Why is that?</p>