get website code problem appear

Any9aby

New member
Joined
Jan 4, 2016
Messages
1
Programming Experience
Beginner
please help me i want get a website code code ,use the post method

this is my code

string postData = "name = aaaaaaaa";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create("http://baidu.lecai.com/user/user_exist.php");
            objWebRequest.Method = "POST";
            objWebRequest.ContentType = "application/x-www-form-urlencoded";
            objWebRequest.ContentLength = byteArray.Length;
            Stream newStream = objWebRequest.GetRequestStream();
            // Send the data. 
            newStream.Write(byteArray, 0, byteArray.Length);
            newStream.Close();


            HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
            StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
            string textResponse = sr.ReadToEnd(); 
            MessageBox.Show(textResponse);


but get code is NULL ,I do not know where the error occurred
 
If what you have posted is actually what you're executing then I think your URL is wrong because it has a space in it. I would think that that would have to be encoded.
 
Back
Top Bottom