Beispiel #1
0
 /// <summary>
 /// URLs the exists.
 /// </summary>
 /// <param name="url">The URL.</param>
 /// <returns></returns>
 public static bool UrlExists(string url)
 {
     using (WebClientWithHeader clientWithHeader = new WebClientWithHeader())
     {
         try
         {
             clientWithHeader.DownloadData(url); // note should be 0-length
             string type = clientWithHeader.ResponseHeaders["content-type"];
             clientWithHeader.HeadOnly = false;
             return(type.StartsWith(@"text/"));
         }
         //dont care
         catch
         {
             return(false);
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// URLs the exists.
 /// </summary>
 /// <param name="url">The URL.</param>
 /// <returns></returns>
 public static bool UrlExists(string url)
 {
     using (WebClientWithHeader clientWithHeader = new WebClientWithHeader())
     {
         try
         {
             clientWithHeader.DownloadData(url); // note should be 0-length
             string type = clientWithHeader.ResponseHeaders["content-type"];
             clientWithHeader.HeadOnly = false;
             return (type.StartsWith(@"text/"));
         }
         //dont care
         catch
         {
             return false;
         }
     }
 }