I'm developing an App for my company, basically we need just a launcher to skip opening the browser and typing the address. I have two text boxes in my app and a login button. It's okay to launch the default browser (OpenAsync works just fine, but I can't pass the credentials). We already have a webapp which requires username and password and we have to reach it from anywhere using a VPN. I'd like to save the credential from the app, send them thru it when pressing the login button and load the page already authenticated. Security is not a concern at the moment since we're not managing private data.
I'm new to this world and I'm not sure how HttpRequests and WebRequests work. I just tryed many solutions i found online, but none of them worked for me. Probably I just miss the point there.
WebRequest request = WebRequest.Create("http://www.example.com/login");
request.Method = "POST";
string postData = "username=usr&password=pass1234";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine(responseFromServer);