title: Can't Post request to login
body: <p>I'm trying to login a website.I'm using httpwebrequest for post login parameters and then I'm trying to get source code of new page.But it gives me "Bad Request";.
  Where is the mistake on my code ?</p>
  
  <pre><code>string formUrl = "https://tr.ogame.gameforge.com:443/main/login"; // NOTE: This is the URL the form POSTs to, not the URL of the form (you can find this in the "action" attribute of the HTML's form tag
          string formParams = string.Format("credentials[email]={0}&amp;credentials[password]={1}&amp;autologin={2}&amp;language={3}&amp;kid={4}", "myUsername", "myPassword","false","tr","");
          string cookieHeader;
          WebRequest req = WebRequest.Create(formUrl);
          req.ContentType = "application/x-www-form-urlencoded";
          req.Method = "POST";
          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"];
          using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
          {
              string pageSource = sr.ReadToEnd();
              txtb.Text = pageSource;
          }
  </code></pre>
  
  <p>Here is result i get ;</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
      &lt;html&gt;&lt;head&gt;
      &lt;title&gt;400 Bad Request&lt;/title&gt;
      &lt;/head&gt;&lt;body&gt;
      &lt;h1&gt;Bad Request&lt;/h1&gt;
      &lt;p&gt;The request could not be understood by the server.&lt;/p&gt;
      &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Here is webpage request headers ;
  <a href="https://i.stack.imgur.com/hBhTk.png" rel="nofollow noreferrer">Screenshot1</a>  <a href="https://i.stack.imgur.com/XarWu.png" rel="nofollow noreferrer">Screenshot2</a></p>