Friday, December 18, 2009

Search on your ASP.NET Website

Many people just don't realize that some most trivial things in IT-life are not that "out-of-the-box-y" at all.
One of them is "Search". Many sites have a Search function, so it is easy to do, right?

I have summarized the approaches to "Search" here:
a. Do your own site search - host it on your server
b. Integrate external search (like Google)

In case of [a] from above: MS indexing service is really a piece of turd when it comes to web indexing, pardon my French, reason being - it does not turn your ASPX files
into static content, it was never built for that so you end-up with an index of your C# code or any other server-side markup.
I know a few people who have "materialized" ASPX and other ASP resources into "/static" folder ,then unleashed MS Indexing on it, then when MS indexing gives you result
, remap "static.html" back into "dynamic.aspx" , and this does suck, but it does work as well!
Another approach in [a] case from above - Google for "ASP.NET indexing" and go buy a dedicated ASP.NET solution of your problem, this sux a ton :(

Now, when you want to utilize Sergey and Larry in [b] case from above, there are quite a few cool features:
if you don't care about how your search result looks - just create a plain HTML form post back to Google with site search parameter preset to your domain.

If you are fastidious as to how search results are "branded" - Google for "Google Search API" and indeed you can customize it, but, what not that many people know, there is a
REST service that returns plain JSON, even with a callback! So, if you are a fan of JQuery, here is a code for you:

$.ajax({  type: "GET", url: "",
data: {q: $("#YOURTEXTBOXID").val(),
callback: "resultReady",
context: "doSearch",
rsz: "large"}, dataType: "script"
and finally:
     function resultReady(ctx, data)
for (var i in data.results)
data.results[i] your stuff dynamically

Google for "Custom Search Engine" to get "YOURCUSTOMSITEID", basically this will allow you to set-up a profile that will
filter searches to URLs that you specify - just what we have needed for a long time!

That's IT!

Remember to check GOOGLE Terms and comply with their logo and other requirements.


Anonymous said...

great post comrade, yo

Anonymous said...

how are you I was fortunate to find your blog in wordpress
your post is quality
I get a lot in your subject really thank your very much
btw the theme of you site is really impressive
where can find it

Anonymous said...

nice post. thanks.

Anonymous said...

I really love your site.. Pleasant colors & theme. Did you create this site yourself?
Please reply back as I'm attempting to create my own site and would love to know where you got this from or just
what the theme is named. Many thanks!

Look into my blog post panic attacks and menstrual cycle

Anonymous said...

TҺis is why it's important to work with a specialist.
Your genes are certainly not solely responsible needed for youг weigҺt then metabolism.

mу blog pօѕt: turbulence training download 2014

Unknown said...

carolina jerseys
texans jerseys
tiffany and co
instyler max
hermes belts
michael kors handbags
seahawks jersey
michael kors outlet
the north face outlet
replica watches