您如何检查网站是否使用C#在线? [英] How do you check if a website is online in C#?
本文介绍了您如何检查网站是否使用C#在线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望我的C#程序在执行之前检查网站是否在线,如何使我的程序ping网站并在C#中检查响应?
I want my program in C# to check if a website is online prior to executing, how would I make my program ping the website and check for a response in C#?
推荐答案
您已使用 System.Net.NetworkInformation.Ping
参见下文。
var ping = new System.Net.NetworkInformation.Ping();
var result = ping.Send("www.google.com");
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
return;
这篇关于您如何检查网站是否使用C#在线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文