Internet Connection Checker (ASP.NET PROGRAM)



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
        Try
            ' Attempt to get response and return True
            objResp = objWebReq.GetResponse
            lbl.Text = "No Intenet Connection"
            objResp.Close()
            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"
        Else
            lbl.Text = "No internet Connection"
        End If
    End Sub
End Class

OUTPUT

Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *