/// <summary> /// 获取链接返回数据 /// </summary> /// <param name="Url">链接</param> /// <param name="type">请求类型</param> /// <returns></returns> public string GetUrltoHtml(string Url, string type) { try { System.Net.WebRequest wReq = System.Net.WebRequest.Create(Url); System.Net.WebResponse wResp = wReq.GetResponse(); System.IO.Stream respStream = wResp.GetResponseStream(); using (System.IO.StreamReader reader = new System.IO.StreamReader(respStream, Encoding.GetEncoding(type))) { return reader.ReadToEnd(); } } catch (System.Exception ex) { return ex.Message; } }
//调用方法
string j = GetUsersHelper.GetUrltoHtml(url, type);//获取微信服务器返回字符串