When calling the method below comes the message
the input string was not in a correct format
private void SubmitData()
{
try
{
string user = usuario.Text;
string pass = senha.Text;
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "username=" + user + "&password=" + pass;
byte[] data = encoding.GetBytes(postData);
WebRequest request = WebRequest.Create("url do site/auth?username=" + user + "&password=" + pass + "");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
WebResponse response = request.GetResponse();
stream = response.GetResponseStream();
StreamReader sr = new StreamReader(stream);
int resultado = int.Parse(sr.ReadLine());
// MessageBox.Show(resultado.ToString());
if (resultado == 1)
{
Form1 segundo = new Form1();
this.Hide();
segundo.ShowDialog();
}
else
{
MessageBox.Show("Your time expired");
usuario.ResetText();
senha.ResetText();
}
sr.Close();
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
}
}