Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows.Forms;
  4. using System.Net.Http;
  5.  
  6. namespace WindowsFormsApplication1
  7. {
  8. public partial class Form1 : Form
  9. {
  10. public Form1()
  11. {
  12. InitializeComponent();
  13. }
  14.  
  15. private void button1_Click(object sender, EventArgs e)
  16. {
  17. Login();
  18. }
  19.  
  20. public void Login()
  21. {
  22. var baseURL = "https://hisweb.fh-nordhausen.de";
  23. var loginURL = "/qisserver/rds";
  24. var user = "xxx";
  25. var pass = "xxx";
  26.  
  27. var client = new HttpClient();
  28. try
  29. {
  30. client.BaseAddress = new Uri(baseURL);
  31.  
  32. var values = new List<KeyValuePair<string, string>>();
  33.  
  34. values.Add(new KeyValuePair<string, string>("asdf", user));
  35. values.Add(new KeyValuePair<string, string>("fdsa", pass));
  36. FormUrlEncodedContent content = new FormUrlEncodedContent(values);
  37.  
  38. var response = client.PostAsync(loginURL, content).Result;
  39. var contents = response.Content.ReadAsStringAsync();
  40.  
  41. Console.WriteLine(response.Content);
  42. Console.WriteLine(response.StatusCode);
  43. }
  44. catch (AggregateException ex)
  45. {
  46. foreach (var item in ex.Flatten().InnerExceptions)
  47. {
  48. Console.WriteLine(item.Message);
  49. }
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement