-1

I am hoping to implement search in my asp.net website. I have been searching the web, but I am not sure which way to go. Here is what I am looking for:

  • ability to search the text in static pages on my site
  • exclude pages or folders that I don't want to search
  • code must be in vb.net or c#
  • must be something I can quickly implement
  • .net 2.0 or later preferred

The best example that I have found so far is http://www.codeproject.com/KB/applications/SearchDotnet.aspx

I like it. I am just hoping to find a more modern one. This one is written in .NET 1.0

Thanks, Erik

vanlandingham
  • 1,079
  • 1
  • 7
  • 4

2 Answers2

0

Hmmm...if you want quick, you should probably go with google integration.

My preferred search engine that you can implement custom is Lucene.NET, however. There should be plenty of examples out there and the documentation is quite good. Depending on your skill level, you may be able to get it in place quickly....but not likely if you're a beginner.

smercer
  • 901
  • 1
  • 6
  • 15
0

To search text in static pages you could try this method below:

  Dim search As String = txtsearch.Text.ToLower
    Dim target As String = web1.DocumentText.ToLower
    Dim counter As Integer = 0
    Dim m As Match = Regex.Match(target, search)

    Do While m.Success
        counter = counter + 1
        m = m.NextMatch()
    Loop

Or:

Dim wb as new WebClient
Dim html as string = wb.DownloadString("http://somesite.com")

To exclude pages, I suggest referring you to the link below. I'm not sure if it will help, but it does provide code and if you need to convert it to vb.net, go to the very bottom link: Exclude files from web site publish in Visual Studio

An example how to implement IndexOf()it is here: https://www.dotnetperls.com/indexof-vbnet

Convert C# to vb.net: https://converter.telerik.com