title: Login to web page without form via c#
body: <p>I am trying to connect to a page to get one value but I ran into a login problem, does anyone have any idea how to solve it?</p>
  <p>I'm working with c# Console App</p>
  <p>Page code:</p>
  <pre><code>&lt;table align=&quot;center&quot;&gt;
              &lt;tr&gt;
                  &lt;td class=&quot;user&quot; &gt;User Name:&lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type=&quot;text&quot; id=&quot;user1&quot; maxlength=&quot;20&quot; onKeyup=&quot;checkUser()&quot; pattern=&quot;^[0-9A-Za-z]+$&quot; autocomplete=&quot;off&quot; autofocus=&quot;&quot; required=&quot;&quot; onkeypress=&quot;onKeydDwnPass(event.keyCode, 1)&quot;/&gt;
                  &lt;/td&gt;
                  &lt;td&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td class=&quot;pass&quot;&gt;Password:&lt;/td&gt;
                  &lt;td&gt;
                      &lt;input id=&quot;pass1&quot; type=&quot;password&quot; maxlength=&quot;32&quot; onKeyup=&quot;checkPass(event.keyCode)&quot; onkeypress=&quot;onKeydDwnPass(event.keyCode, 2)&quot; autocomplete=&quot;off&quot; required=&quot;&quot;/&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;input type=&quot;button&quot; id=&quot;loginbtn&quot; class=&quot;loginbtn&quot; value=&quot;Log on&quot; onclick=&quot;LogInStart()&quot;/&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  </code></pre>
  <p>My C# Code:</p>
  <pre><code>string cookieHeader;
          string formParams = string.Format(&quot;user1={0}&amp;pass1={1}&quot;, &quot;operator&quot;, &quot;1234Test&quot;);
          byte[] bytes = Encoding.ASCII.GetBytes(formParams);
          WebRequest req = WebRequest.Create(_formUrlTransSystem + $&quot;system/Log-in.html&quot;);
          req.ContentType = &quot;application/x-www-form-urlencoded&quot;;
          req.Method = &quot;POST&quot;;
          req.ContentLength = bytes.Length;
  
          using (Stream os = req.GetRequestStream())
          {
              os.Write(bytes, 0, bytes.Length);
          }
          Console.Beep();
          WebResponse resp = req.GetResponse();
          cookieHeader = resp.Headers[&quot;Set-cookie&quot;];
          Console.WriteLine(cookieHeader);
          return cookieHeader;
  </code></pre>
  <p>Can someone tell me how to pass the login data to the fields and trigger the button press?</p>