private string GetPage(string url,string indata)
{
Uri _uri = new Uri( url );
Stream stream = null;
StreamReader reader = null;
HttpWebResponse response = null;
HttpWebRequest request = null;
try
{
request = (HttpWebRequest)HttpWebRequest.Create(_uri);//读取文件
request.ContentType="application/x-www-form-urlencoded";
request.ContentLength=indata.Length;
request.Method="POST";
Stream myRequestStream=request.GetRequestStream();
StreamWriter myStreamWriter=new StreamWriter(myRequestStream,Encoding.GetEncoding("gb2312"));
myStreamWriter.Write(indata);
//把数据写入HttpWebRequest的Request流
myStreamWriter.Close();
myRequestStream.Close();
response=(HttpWebResponse)
request.GetResponse();
stream =
response.GetResponseStream();
string buffer = "";
reader = new StreamReader
(stream,System.Text.Encoding.Default);
buffer = reader.ReadToEnd();
return buffer;
}
catch(Exception err)
{
err.ToString();
return null;
}
finally
{
if( reader!=null ) reader.Close
();
if( stream!=null ) stream.Close
();
if( response!=null )
response.Close();
}
}