浏览器访问http://xxxxx/ss?date=2012-07-01 得到所需的字符串
先 我用post的方法 将日期post 过去
但提示 http 500 错误
代码如下
string postData = " date=" + date + "";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(" http://http://xxxxx/ss");
objWebRequest.Method = "POST";
objWebRequest.ContentType = "application/x-www-form-urlencoded";
objWebRequest.ContentLength = byteArray.Length;
Stream newStream = objWebRequest.GetRequestStream(); newStream.Write(byteArray, 0, byteArray.Length); newStream.Close(); HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
textResponse = sr.ReadToEnd();
先 我用post的方法 将日期post 过去
但提示 http 500 错误
代码如下
string postData = " date=" + date + "";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(" http://http://xxxxx/ss");
objWebRequest.Method = "POST";
objWebRequest.ContentType = "application/x-www-form-urlencoded";
objWebRequest.ContentLength = byteArray.Length;
Stream newStream = objWebRequest.GetRequestStream(); newStream.Write(byteArray, 0, byteArray.Length); newStream.Close(); HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
textResponse = sr.ReadToEnd();
string address = "http://xxxxx/s?date=";
WebClient client = new WebClient();
string reply = client.DownloadString(address);搞定了 没有用这个post 实在没有找到为什么 。用的下面的方法