daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Jan 25th, 2016 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private async void loginButton_Click(object sender, RoutedEventArgs e)
  2.         {
  3.             var username = this.usernameBox.Text;
  4.             var password = this.passwordBox.Text;
  5.  
  6.             var serverURL = "http://localhost:3000/users/login";
  7.  
  8.             var values = new List<KeyValuePair<string, string>>
  9.                     {
  10.                         new KeyValuePair<string, string>("email", username),
  11.                         new KeyValuePair<string, string>("password", password)
  12.                     };
  13.             var httpClient = new HttpClient(new HttpClientHandler());
  14.             var message = new FormUrlEncodedContent(values);
  15.             HttpResponseMessage response = await httpClient.PostAsync(serverURL, message);
  16.             try
  17.             {
  18.                 response.EnsureSuccessStatusCode();
  19.                 var responseString = await response.Content.ReadAsStringAsync();
  20.             }
  21.             catch (System.Net.Http.HttpRequestException exception)
  22.             {
  23.                 this.errorText.Text = "Error occured when trying to connect.";
  24.             }
  25.  
  26.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top