标签:
/// <summary> /// 远程获取页面数据 /// </summary> /// <param name="Url">地址</param> /// <returns></returns> public static string GetHttpData(string Url) { //string sException = null; string sRslt = null; WebResponse oWebRps = null; WebRequest oWebRqst = WebRequest.Create(Url); oWebRqst.Timeout = 50000; //try //{ oWebRps = oWebRqst.GetResponse(); //} //catch (WebException e) //{ // sException = e.Message.ToString(); // HttpContext.Current.Response.Write(sException); //} //catch (Exception e) //{ // sException = e.ToString(); // HttpContext.Current.Response.Write(sException); //} //finally //{ if (oWebRps != null) { StreamReader oStreamRd = new StreamReader(oWebRps.GetResponseStream(), Encoding.UTF8); sRslt = oStreamRd.ReadToEnd(); oStreamRd.Close(); oWebRps.Close(); } //} return sRslt; }
标签:
原文地址:http://www.cnblogs.com/Aamir-Ye/p/4571624.html