跳至主要內容

windows uwp怎確認網站是否可存取

Last Updated on 2025-02-07 by william

   try
{
var request = WebRequest.Create("https://tw.yahoo.com");
request.Timeout = 5000;
request.Method = "HEAD";

using (var response = (HttpWebResponse)request.GetResponse())
{
String s = response.StatusCode.ToString();
response.Close();
return s.Equals(System.Net.HttpStatusCode.OK.ToString());
}
}
catch (System.Net.WebException exception)
{
return false;
}
分類:未分類

搶先發佈留言

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

由 Compete Themes 設計的 Author 佈景主題