Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using System.Net.Http;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Login();
- }
- public void Login()
- {
- var baseURL = "https://hisweb.fh-nordhausen.de";
- var loginURL = "/qisserver/rds";
- var user = "xxx";
- var pass = "xxx";
- var client = new HttpClient();
- try
- {
- client.BaseAddress = new Uri(baseURL);
- var values = new List<KeyValuePair<string, string>>();
- values.Add(new KeyValuePair<string, string>("asdf", user));
- values.Add(new KeyValuePair<string, string>("fdsa", pass));
- FormUrlEncodedContent content = new FormUrlEncodedContent(values);
- var response = client.PostAsync(loginURL, content).Result;
- var contents = response.Content.ReadAsStringAsync();
- Console.WriteLine(response.Content);
- Console.WriteLine(response.StatusCode);
- }
- catch (AggregateException ex)
- {
- foreach (var item in ex.Flatten().InnerExceptions)
- {
- Console.WriteLine(item.Message);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement