01.public string tm4b(string sURL, bool bEscapeURL, string sPostData)
02.{
03.sURL = sURL.Trim();
04.while (sURL.IndexOf(" ") > 0)
05.{
06.sURL = sURL.Replace(" ", " ");
07.}
08.System.Text.StringBuilder sb = new System.Text.StringBuilder();
09.string stmp = string.Empty;
10.Uri httpUri = new Uri(sURL, bEscapeURL);
11.try
12.{
13.
14.System.Text.ASCIIEncoding byteConverter = new System.Text.ASCIIEncoding();
15.byte[] byte1 = byteConverter.GetBytes(sPostData);
16.System.Net.HttpWebRequest hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(httpUri);
17.
18.hwRequest.ContentType = "application/x-www-form-urlencoded";
19.hwRequest.Method = "POST";
20.
21.hwRequest.ContentLength = sPostData.Length; ;
22.System.IO.Stream PostStream = hwRequest.GetRequestStream();
23.PostStream.Write(byte1, 0, byte1.Length);
24.System.Net.HttpWebResponse hwResponse = (System.Net.HttpWebResponse)hwRequest.GetResponse();
25.System.IO.StreamReader sRead = new System.IO.StreamReader(hwResponse.GetResponseStream(),
26.System.Text.Encoding.ASCII);
27.
28.if ((stmp = sRead.ReadLine()) != null)
29.{
30.
31.sb.Append(stmp + "");
32.
33.}
34.
35.PostStream.Close();
36.sRead.Close();
37.
38.return sb.ToString();
39.
40.}
41.catch (Exception ex)
42.{
43.
44.return "error";
45.}
46.return "Request Error";
47.
48.}