你的位置:首页 > ASP.net教程

[ASP.net教程]在c#中get同步访问http


参照文章:http://blog.csdn.net/qianmenfei/article/details/37974767

public static string SendMessage(string url, Encoding encode = null)    {      string result;      try      {        var webClient = new WebClient { Encoding = Encoding.UTF8 };        if (encode != null)          webClient.Encoding = encode;        result = webClient.DownloadString(url);      }      catch (Exception ex)      {        result = ex.Message;      }      return result;    }