Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task<string> getData()
- {
- ASCIIEncoding encoding = new ASCIIEncoding();
- string postData = string.Format("school={0}&username={1}&password={2}", "schoolcode", "username", "password");
- byte[] data = encoding.GetBytes(postData);
- WebRequest request = WebRequest.Create("https://example.com/login");
- request.Method = "POST";
- request.ContentType = "application/x-www-form-urlencoded";
- request.Headers["ContentLength"] = data.Length.ToString();
- Stream stream = await request.GetRequestStreamAsync();
- stream.Write(data, 0, data.Length);
- WebResponse response = await request.GetResponseAsync();
- stream = response.GetResponseStream();
- StreamReader sr = new StreamReader(stream);
- string res = await sr.ReadToEndAsync();
- return res;
- }
- Stream stream = await request.GetRequestStreamAsync();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement