The query contained only ignored words

I am using .NET to query indexing server (search engine for our Intranet)
If the user searches for "the" or "a" etc they will get an error page stating - The query contained only ignored words.
What is the best way to catch this and deliver something meaningful back to the page. I'd rather do this than have a huge array of ignored words (noise) to compare against.
LVL 29
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

BakuRetsu_XConnect With a Mentor Commented:
    Do what you're doing
Catch ex as Exception
   Response.Redirect("the page you're on")
End Try
QPRAuthor Commented:
Is there a way to echo to the user what they have done wrong so they can be educated.
If I just use a generic catch ex then the message I relay may have nothing to do with what they have done (on this occasion)
An easy way would be to do a redirect to the page that you're on, with some information .. for example... Response.Redirect("ThePage.aspx?error=You pressed the wrong button")

Then on that page, in the onload section.  You can set a variable or a text on that page to display the error.

something like,
' This retrieves the error message
Dim error as string = httpcontext.current.request.querystring("error").trim

' This creates a textbox and inserts it onto the aspx page.  you can create just about anything to insert on your page with the error message.  It can be a DIV, Span, html link, anything..  Here i'm using a textbox

If Not string.isnullorempty(error) Then
 Dim errorTextBox as New TextBox
 With errorTextBox
     .Text = error
    ' Do other things to format this message here
 End With
 ' Pick a control such as a DIV, SPAN, or Asp Panel with an ID on your aspx page  that runs on the server
  'Do Nothing
End If
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

QPRAuthor Commented:
Thanks but I want (if possible) to be able to catch that particular error (the one in the question). I have no problem redirecting in the catch block. But I can't guaruantee that the error will always be that one.
Example if the person searches for "a valid phrase" and, for some reason, the IS service is not running... the error would be indexing service is currently available but I would be telling the user there search string is invalid leaving them confused and unlikely to use the search function.
you will have to trap that particular error then.

do you know what error it throws?  If you do, then you can catch it. I'm assuming that the error is thrown and page is redirected based on a sql statement or error of some sort.

You don't have to manually create a dictionary to check it against if you know how it is checking this.  

Of if you must, put all of those words into a sql table and just do a sql querry against it.

See if you can trap and print the error.  Once you know more details of the error, you can better trap it.
QPRAuthor Commented:
The error comes from indexing server (which is what I am querying) there is not redirection just a .net error page, if I were to turn on custon errors (which I will when we go live) then the user would just see internet explorer cannot display this page etc. When back at work later I will check for error numbers. The text for the error is.... The query contained only ignored words
So if you put that query inside a try block, it still won't catch anything?  If you can catch it, try to echo the error.

If not, then you will have to understand how the index server is processing this information and go from there.

All Courses

From novice to tech pro — start learning today.