本文實例講述了C#實現發送簡單HTTP請求的方法。分享給大家供大家參考。具體如下:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;namespace WRApp{ class Program { static void Main(string[] args) { WebRequest req = WebRequest.Create ("http://www.49028c.com"); WebResponse resp = req.GetResponse(); StreamReader reader = new StreamReader(resp.GetResponseStream(),Encoding.ASCII); Console.WriteLine(reader.ReadToEnd()); } }}
希望本文所述對大家的C#程序設計有所幫助。
新聞熱點
疑難解答