© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
Quick Links
Easy Studies

  HomeSource Code DotNet ► Asp.Net ▼

Internet Connection Checker

This article is about how you can check either your internet connection is working or not.

Imports System.Data
Imports System.Drawing

Partial Class _Default
    Inherits System.Web.UI.Page
      Public Function IsConnectionAvailable() As Boolean
        Dim objUrl As New System.Uri("http://www.yoursite.com/")
        ' Setup WebRequest
        Dim objWebReq As System.Net.WebRequest
        objWebReq = System.Net.WebRequest.Create(objUrl)
        Dim objResp As System.Net.WebResponse
            ' Attempt to get response and return True
            objResp = objWebReq.GetResponse
            lbl.Text = "No Intenet Connection"
            objWebReq = Nothing

            Return True
        Catch ex As Exception
            objWebReq = Nothing
            Return False
        End Try
    End Function
    Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click
        If IsConnectionAvailable() = True Then
            lbl.Text = "You are in online"
            lbl.Text = "No internet Connection"
        End If
    End Sub
End Class




SLogix Student Projects