Wednesday, August 19, 2009

How to check My link on another website (Reciprocal Link) in ASP.Net 2.0

Imports System.Net
Imports System.IO
Imports System.IO.FileStream

Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click
Dim client As WebClient = New WebClient
Dim str As Stream = client.OpenRead("http://www.AnotherWebsiteName.com/")
Dim reader As StreamReader = New StreamReader(str)
Dim content As String = reader.ReadToEnd
Dim myURL As String = "http://www.MyWebSite.com/"
Dim LinkExists As Boolean = False
If content.ToLower().IndexOf(myURL) >= 0 Then
LinkExists = True
Response.Write("My Link Exists")
Else
Response.Write("My Link Not Found")
End If
End Sub