从C#控制台应用程序我需要打开Web浏览器,我想要输出.这是链接中的服务器名称.如果Internet Explorer没有显示任何内容,则表示服务器已启动.如果我得到Internet Explorer无法显示网页,那么这意味着服务器已关闭.
下面是打开IE的代码
Process.Start("https://foo.com");
Run Code Online (Sandbox Code Playgroud)
如果Internet Explorer显示一个空页面,那么服务器将关闭服务器.
并想知道浏览器如何自动关闭?
using(WebClient client = new WebClient())
{
string pageData;
try
{
pageData = client.DownloadString(yourAddress);
}
catch(Exception e)
{
//something went wrong. Maybe the site is down?
}
//does pageData have expected content?
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1235 次 |
最近记录: |