hi
i have try to solved this problem but i can't
i want login into website with HttpClient but i want to know when login failed
this is my code :
static void Main(string[] args)
{
login(@"http://www.test.com/", "a784512", "112233445").Wait();
Console.ReadKey();
}
private static async Task login(string host, string username, string password)
{
var client = new HttpClient();
client.BaseAddress = new Uri(host);
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("j_username", username),
new KeyValuePair<string, string>("j_password", password)
});
var result = await client.PostAsync("login.html", content);
var ok = result.IsSuccessStatusCode;
Console.WriteLine((int)result.StatusCode);
Console.WriteLine();
Console.WriteLine(ok.ToString());
Console.WriteLine(result.Headers.Location);
}
as you see i tried to get some error or anything ... this is a point that we send wrong username or password we get status 200
only different between right login and bad login is in response parameter that in wrong data we receive error:true
so .. what must i do ?
What I have tried:
read status code -> not result
read back param -> i cant find this param