C#教程

关注公众号 jb51net

关闭
首页 > 软件编程 > C#教程 > C#发送简单HTTP请求

C#实现发送简单HTTP请求的方法

作者:令狐不聪

这篇文章主要介绍了C#实现发送简单HTTP请求的方法,涉及C#操作http的技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了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 ("https://www.jb51.net");
   WebResponse resp = req.GetResponse();
   StreamReader reader = new StreamReader(resp.GetResponseStream(),Encoding.ASCII);
   Console.WriteLine(reader.ReadToEnd());
  }
 }
}

希望本文所述对大家的C#程序设计有所帮助。

您可能感兴趣的文章:
阅读全文