c# http请求,获取非200时的响应体

 HttpWebResponse res = null;
        try
        {
            res = request.GetResponse() as HttpWebResponse;

        }
        catch (WebException ex)
        {
            res = (HttpWebResponse)ex.Response;
            //string html = new StreamReader(temp.GetResponseStream()).ReadToEnd();
            //StreamReader sr = new StreamReader(res.GetResponseStream());
            //string html = sr.ReadToEnd();

        }

 

posted @ 2017-04-22 10:29  小小高  阅读(1219)  评论(0编辑  收藏  举报