asp.net 获取远程页面的返回值(post)
protected void Button1_Click(object sender, EventArgs e) { //这是一个短信平台的后台提交功能 string postData = string.Format("ServerId={0}&account={1}&password={2}&roleId={3}", "1", "008", "007369852147","1"); // 要发放的数据 byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postData); HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create("http://192.168.1.8:1986/ntkoSignServer/addntkouser"); //发送地址 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(), System.Text.Encoding.Default); string textResponse = sr.ReadToEnd() + "返回数据"; // 返回的数据 Response.Write(textResponse);//打印返回值 }