title: How to check if website is up?
body: <p>I'm learning about vb.net and was wondering how I would check for a website, if it is up, set a public shared, if it is down, use a different public shared?</p>
  
  <p>I currently have the code as </p>
  
  <pre><code>Public Shared domain As String = "domain"
  </code></pre>
  
  <p>But I'm confused as how to make it check the site when I launch the application and then run the check.</p>
  
  <p>--- Edit this is what I have now,</p>
  
  <pre><code>Dim URL As String = "https://www.personalblog.com"
  
  Public Shared Function IsWebpageOnline(ByVal URL As String) As Boolean
      Try
          Dim req As WebRequest = WebRequest.Create(URL)
          Dim res As WebResponse = req.GetResponse()
      Catch ex As Exception
          Return False
      End Try
      Return True
  End Function
  
   If IsWebpageOnline = 1 Then
  Public Shared domain As String = "blog.com"
   Else
  Public Shared domain As String = "backupblog.com"
   End If
  </code></pre>