Exemplo n.º 1
0
        public async Task GetRequest(string un, string pw)
        {
            client = new HttpClient();
            using (client)
            {
                client.BaseAddress = new Uri("http://localhost:54281/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage res = await client.GetAsync("api/Account/?username=" + un);

                if (res.IsSuccessStatusCode)
                {
                    AccountClient account = await res.Content.ReadAsAsync <AccountClient>();

                    if (account.password == pw)
                    {
                        check = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     /*GetRequest(username, password).Wait();
      * if (check)
      * {
      *  this.Hide();
      *  Main ss = new Main();
      *  ss.Show();
      * }
      * else
      * {
      *  MessageBox.Show("Incorrect Username or Password");
      * }*/
     client = new HttpClient();
     using (client)
     {
         client.BaseAddress = new Uri("http://localhost:54281/");
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         HttpResponseMessage res = client.GetAsync("api/Account/?username="******"Incorrect Username or Password");
             }
         }
     }
 }