网站建设部署视频,修改散文网站,做网站的支付,网站价位C# -- HttpWebRequest 和 HttpWebResponse 的使用 结合使用HttpWebRequest 和 HttpWebResponse#xff0c;来判断一个网页地址是否可以正常访问。 1.举例 class Program{static void Main(string[] args){string strUrl https://www.baidu.com;HttpWebRequest wr…C# -- HttpWebRequest 和 HttpWebResponse 的使用 结合使用HttpWebRequest 和 HttpWebResponse来判断一个网页地址是否可以正常访问。 1.举例 class Program{static void Main(string[] args){string strUrl https://www.baidu.com;HttpWebRequest wreq (HttpWebRequest)WebRequest.Create(strUrl);HttpWebResponse wrsp (HttpWebResponse)wreq.GetResponse();if (wrsp.StatusCode HttpStatusCode.OK){Console.WriteLine(strUrl --http response正常\r\n); }else{Console.WriteLine(strUrl --http response出现异常\r\n); }Console.ReadKey();}} 2. 运行结果 转载于:https://www.cnblogs.com/ChengWenHao/p/CSharpHttpWebRequestAndHttpWebResponse.html