Answer the question
In order to leave comments, you need to log in
c# how to get bool from webrequest?
private void SubmitData()
{
try
{
string user = login.Text;
string pass = password.Text;
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "login=" + user + "&password=" + pass;
byte[] data = encoding.GetBytes(postData);
WebRequest request = WebRequest.Create("https://site.ru/auth.php");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
WebResponse response = request.GetResponse();
stream = response.GetResponseStream();
StreamReader sr = new StreamReader(stream);
MessageBox.Show(sr.ReadToEnd());
sr.Close();
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}
Answer the question
In order to leave comments, you need to log in
judging by the previous question "how to get authorization for a c # application from php" - is this the second part?
just read at your leisure what HTTP is and how it works
, in this case it is not necessary to wrap bool, but rather 200 OK /
401
Unauthorized at the same time, learn what using is, otherwise it hurts your eyes to look
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question