Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. function for urlcheck

function for urlcheck

Scheduled Pinned Locked Moved ASP.NET
databasetutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cyus
    wrote on last edited by
    #1

    hi there, can any one tell me how to write a function to check the validate url in database Thanks in advance cyus

    J 1 Reply Last reply
    0
    • C cyus

      hi there, can any one tell me how to write a function to check the validate url in database Thanks in advance cyus

      J Offline
      J Offline
      Javier Lozano
      wrote on last edited by
      #2

      Could you provide more information on what you're trying to accomplish? ~Javier Lozano

      A C 2 Replies Last reply
      0
      • J Javier Lozano

        Could you provide more information on what you're trying to accomplish? ~Javier Lozano

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Hii javier, this is the scenario i have a database which has 2000 records in that one field is url will i have to check whether the given url is having valid connection r broken connection for that iam using a function which is the following... cod snippet Public Function checkurl(ByVal url As String) As String Dim req As System.Net.HttpWebRequest Dim res As System.Net.HttpWebResponse Dim r As System.IO.StreamReader Dim ex As Exception 'error exeption holder Dim pge As String 'page holder ' If Page.IsPostBack Then 'ReqUrl.Text = Textbox1.Text 'set up error trapping Dim strerr As String = "" Try 'display request url req = req.Create(url) 'set the user agent 'some site might brush you off if it is not set 'to stop bots and scrapers req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)" 'get page res = req.GetResponse() r = New System.IO.StreamReader(res.GetResponseStream()) pge = r.ReadToEnd r.Close() res.Close() 'display respondent url Dim struri As String = res.ResponseUri.AbsoluteUri 'extract and display meta refresh tag, if it exists Dim strpge As String = System.Text.RegularExpressions.Regex.Match(pge, "URL=(?[^""]+)""").Groups("href").Value() 'extract and display page title Dim strtit As String = System.Text.RegularExpressions.Regex.Match(pge, "(?<title>[^<]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Groups("title").Value Dim SHhash As New System.Security.Cryptography.SHA1Managed 'convert the page to a byte array Dim pgeb As Byte() = System.Text.Encoding.ASCII.GetBytes(pge) 'get the hash as a byte array Dim hashvalue As Byte() = SHhash.ComputeHash(pgeb) 'display the hash as a string strerr = "" Catch ex 'display any error message strerr = ex.Message End Try End Function Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then 'SqlDataAdapter1.Fill(DsResult) 'DataGrid1.DataBind() If DsResult.Tables(0).Rows.Count >

        1 Reply Last reply
        0
        • J Javier Lozano

          Could you provide more information on what you're trying to accomplish? ~Javier Lozano

          C Offline
          C Offline
          cyus
          wrote on last edited by
          #4

          Hi javier, this is the scenario i have a database which has 2000 records in that one field is url will i have to check whether the given url is having valid connection r broken connection for that iam using a function which is the following... the code snippet Public Function checkurl(ByVal url As String) As String Dim req As System.Net.HttpWebRequest Dim res As System.Net.HttpWebResponse Dim r As System.IO.StreamReader Dim ex As Exception 'error exeption holder Dim pge As String 'page holder 'set up error trapping Dim strerr As String = "" Try 'display request url req = req.Create(url) 'set the user agent 'some site might brush you off if it is not set 'to stop bots and scrapers req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)" 'get page res = req.GetResponse() r = New System.IO.StreamReader(res.GetResponseStream()) pge = r.ReadToEnd r.Close() res.Close() 'display respondent url Dim struri As String = res.ResponseUri.AbsoluteUri 'extract and display meta refresh tag, if it exists Dim strpge As String = System.Text.RegularExpressions.Regex.Match(pge, "URL=(?[^""]+)""").Groups("href").Value() 'extract and display page title Dim strtit As String = System.Text.RegularExpressions.Regex.Match(pge, "(?<title>[^<]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Groups("title").Value Dim SHhash As New System.Security.Cryptography.SHA1Managed 'convert the page to a byte array Dim pgeb As Byte() = System.Text.Encoding.ASCII.GetBytes(pge) 'get the hash as a byte array Dim hashvalue As Byte() = SHhash.ComputeHash(pgeb) 'display the hash as a string strerr = "" Catch ex 'display any error message strerr = ex.Message End Try End Function Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then SqlDataAdapter1.Fill(DsResult) 'DataGrid1.DataBind() If DsResult.Tables(0).Rows.Count > 0 Then For I As Integer = 0 To DsResult.Tables(0).Rows.Coun

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups