Antony Xavier

Antony Xavier

  • NA
  • 7
  • 996

Call WebApi Link to Windows form for Login Authentication

Feb 7 2020 12:08 AM
using (var client = new HttpClient())
{
string data = txtPass.Text;
string password = Encrypt(data);
HttpResponseMessage response = Client.GetAsync("api/Values/Login?UserLogin = '" + txtUser.Text + "' & Password = '" + password + "'").Result;
 client.BaseAddress = new Uri("http://qaen.hr2eazy.com/MobileAPI/");
LoginClass lgn = new LoginClass { Email = txtUser.Text.ToString(), Password = txtPass.Text.ToString() };
 var response = client.PostAsJsonAsync("api/Values/Login? UserLogin = '" + txtUser.Text + "' and Password = '" + password + "'", lgn).Result;
 
var a = response.Content.ReadAsStringAsync();
if (a.Result.ToString().Trim() == "0")
{
MessageBox.Show("Invalid Username");
}
else
{
MessageBox.Show ("Login Successful");
Main f = new Main();
f.Show();
this.Hide();
}
}

Answers (2)