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?
I'm working with c# Console App
Page code:
<table align="center">
<tr>
<td class="user" >User Name:</td>
<td>
<input type="text" id="user1" maxlength="20" onKeyup="checkUser()" pattern="^[0-9A-Za-z]+$" autocomplete="off" autofocus="" required="" onkeypress="onKeydDwnPass(event.keyCode, 1)"/>
</td>
<td></td>
</tr>
<tr>
<td class="pass">Password:</td>
<td>
<input id="pass1" type="password" maxlength="32" onKeyup="checkPass(event.keyCode)" onkeypress="onKeydDwnPass(event.keyCode, 2)" autocomplete="off" required=""/>
</td>
<td>
<input type="button" id="loginbtn" class="loginbtn" value="Log on" onclick="LogInStart()"/>
</td>
</tr>
</table>
My C# Code:
string cookieHeader;
string formParams = string.Format("user1={0}&pass1={1}", "operator", "1234Test");
byte[] bytes = Encoding.ASCII.GetBytes(formParams);
WebRequest req = WebRequest.Create(_formUrlTransSystem + $"system/Log-in.html");
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.ContentLength = bytes.Length;
using (Stream os = req.GetRequestStream())
{
os.Write(bytes, 0, bytes.Length);
}
Console.Beep();
WebResponse resp = req.GetResponse();
cookieHeader = resp.Headers["Set-cookie"];
Console.WriteLine(cookieHeader);
return cookieHeader;
Can someone tell me how to pass the login data to the fields and trigger the button press?