C#通过http协议

   StreamReader din = File.OpenText("url_ys.txt");               

              str = din.ReadLine();                din.Close();

                // 设置打开页面的参数

Stringurl=http://127.0.0.1:8060/myjob;

HttpWebRequestrequest=WebRequest.Create(url)asHttpWebRequest;

request.Method="GET";

request.KeepAlive=false;

                request.Timeout = 5000;

                // 接收返回的页面

HttpWebResponseresponse=request.GetResponse()asHttpWebResponse;

System.IO.StreamresponseStream=response.GetResponseStream();

System.IO.StreamReaderreader=newSystem.IO.StreamReader(responseStream,Encoding.Default);

                String srcString = reader.ReadToEnd();

                reader.Close();                response.Close();

                UI ui = new UI(srcString);

                reader.Close();

response.Close();

相关推荐