EDITED
I managed to make a simple app allows me to login to the site but the problem is I need to make the app redirect to another page when I enter the correct username and password.
Notice that upon entering the wrong username or password a message pops up and contains the whole source code of the site.
How can I select a certain phrase like " Error "
from the source code to tell the app that this there is an incorrect username or password or make that phrase the only thing that pops up?
private void SubmitData()
{
try
{
string username = textBox1.Text;
string password = textBox2.Text;
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "username" + username+ "&password" + password;
byte[] data = encoding.GetBytes(postData);
WebRequest request = WebRequest.Create("url");
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);
MessageBox.Show(sr.ReadToEnd());
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
}