C#实现发送简单HTTP请求的方法
内容摘要
本文实例讲述了C#实现发送简单HTTP请求的方法。分享给大家供大家参考。具体如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Tex
using System;
using System.Collections.Generic;
using System.Linq;
using System.Tex
文章正文
本文实例讲述了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.phpstudy.net"); WebResponse resp = req.GetResponse(); StreamReader reader = new StreamReader(resp.GetResponseStream(),Encoding.ASCII); Console.WriteLine(reader.ReadToEnd()); } } }
希望本文所述对大家的C#程序设计有所帮助。
代码注释