C# 如何发送Http请求

HttpSender是一个用来发送Http消息的轻量库,使用非常简单

使用 Nuget,搜索 HttpSender 就能找到

命名空间是HttpSender,类名是Sender

方法如下

发送 Get 请求

static string Get(string url)

发送 Post 请求

static string Post(string url,string content)
static string Post(string url, Dictionary<string,string> content)

发送 Put 请求

static string Put(string url)
static string Put(string url, Dictionary<string,string> content)

发送 Delete 请求

static string Delete(string url)

在Http头部中设置 OAuth 令牌

static void OAuth(string token)