|
程序通过httphelper获得了一个网页的全部内容,我想通过POST方式将得到的网页内容传到另外一张网页上接收,现在程序提供500错误,我将主要代码附上,请大大们帮忙指点一下。 static void Main(string[] args)
{
string Bz1=null;
HttpWebRequest myreq = (HttpWebRequest)WebRequest.Create("http://XXXXXXX.aspx");
Bz1 = WebResponseGet(myreq);
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://localhost:55850/exchange.aspx",
Method = "POST",
Encoding = null,
Postdata = "bz1="+Bz1+"id=1&fs=u",
ContentType = "application/x-www-form-urlencoded;charset=gb2312",
PostDataType=PostDataType.Byte,
};
HttpResult result = http.GetHtml(item);
result = http.GetHtml(item);
Console.WriteLine(result.Html);
Console.ReadLine();
}
public static string WebResponseGet(HttpWebRequest webRequest)
{
StreamReader responseReader = null;
string responseData = null;
try
{
responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
responseData = responseReader.ReadToEnd();
}
catch
{
return "页面无响应";
}
finally
{
webRequest.GetResponse().GetResponseStream().Close();
responseReader.Close();
responseReader = null;
}
return responseData;
}
|
|