Adding search to your site using the MSN Search Web Service

I was going to write about this in the past before all the issues I had with my blog but it looks like it’s good I didn’t! It just got a loot easier. A couple of months ago I was trying to play with the MSN Search Web service to see if I can add search functionality to my site.

I tried to do so by following this article, and my advice is, don’t! Back then I got a bit confused by it and it seemed that some info was missing. Also a lot of the components such as the AntiXSS library were not even included and you had to search for them to get them included.

Now you don’t have to do any of this! Thanks to this download. The download includes all the files you need to get the search functionality included in your site.

The only thing you need to do is go and grab a search API ID from hereand place that into your source code, you can either do this by adding a key with the obtained value into your Web.Config file or by entering the value in the appropriate place in the SearchProxy.aspx file, and this should be all! Well almost!

The only thing left to do from here is that you specify which site/sites you want the search to operate on this is done by replacing the following code that exists in the Default.html file in the source downloaded from the link mentioned earlier, with the values that you want.

var sc = new searchClient(‘keyAndCount’, ‘returnArea’, “(”);

So in this case I’ve set that value to search my blog site.

I wish I’ve seen this stuff a few month ago! Would have made my experimentation a lot easier 🙂