日期:2014-05-18  浏览次数:20883 次

帮忙看看怎么接受不到数据呢?在屏幕上显示不出来呢.这是怎么回事.
using   System;
using   System.Collections;
using   System.ComponentModel;
using   System.Data;
using   System.Net   ;
using   System.IO   ;
using   System.Text   ;
using   System.Text.RegularExpressions;
using   System.Web   ;

namespace   WindowsApplication5
{
public   class   Post
{
public   static   void   Main(string   []   args)
{
Post   zhucheng=new   Post();
zhucheng.zhuchengxu();

}
public   void   zhuchengxu()
{
try
{
ASCIIEncoding   encoding=new   ASCIIEncoding();
string   postData= "COMMANDID=05 ";
byte[]     data   =   encoding.GetBytes(postData);
//   Prepare   web   request
HttpWebRequest   myRequest   =(HttpWebRequest)WebRequest.Create( "http://61.156.3.58/test.jsp ");
myRequest.Method   =   "POST ";
myRequest.ContentType= "application/x-www-form-urlencoded ";
myRequest.ContentLength   =   data.Length;
Stream   newStream=myRequest.GetRequestStream();
//   Send   the   data.
newStream.Write(data,0,data.Length);
newStream.Close();
HttpWebResponse     webResponse=(HttpWebResponse)myRequest.GetResponse();    
Stream   stream=webResponse.GetResponseStream();
System.IO.StreamReader   streamReader   =   new   StreamReader(stream,   System.Text.Encoding.GetEncoding( "GB2312 "));
string   content   =   streamReader.ReadToEnd();
//   关闭相关对象
Console.WriteLine   (content);
streamReader.Close();
webResponse.Close();
}

catch(Exception   ed   )  
{  
Console.WriteLine   (   "发生 "   +   ed.ToString()+ "错误! "   )   ;  
}
}
}
}


------解决方案--------------------
up
------解决方案--------------------
myRequest.ContentType=

------解决方案--------------------
mark 学习