Skip Navigation LinksFront Page > Archive > Search Your Site Using MSN Search
posted on:6/7/2005 1:37:27 AM
msn logo When the new msn search launched it didn't take me long to notice the rss button at the bottom of each search result listing. At first I thought the notion was completely absurd. In all honesty I cannot think of any good reason to subscribe to search results in an rss reader or you mail client. As I investigated a little bit more I noticed that the results were driven by the query string and that I could in fact adjust my results by adjusting the query string. I quickly realized that you could include msn search results in your application or web site by aggregating this data. Like google search msn supports the search word "site:yoursite.com", So by combining these 2 features you can create a search engine for your own site using msn's results.

In the example below I am building the query string on the fly with the searchstring typed in my web form. I then parse the Rss feed with a xsl style sheet and display the results. The pagination is accomplished by passing parameters to the XSL file and handling the pagination within the xsl. To view this example click the link below.

MSN Site Search Example

msn men As you can see the search works very well and is very fast. You can try searching my site for something like "asp" or "xml" to generate a sufficient amount of search results.

I am making my code available for download please feel free to download it and use it on your site. It will work on any server that will run asp.net. There are only 2 variables that you need to change to personalize the search results to your site. In the aspx file you will find 2 variables "sitename" and "resultcount". Sitename is the fully qualified domain name of your site and resultcount specifies the total number of results to return. You may want to adjust this based on the amount of content you have. The less total results you download on each query the faster it will run.

MSN Site Search Example - Download Source Code (.zip)

Google Site Search vs. MSN Site Search

In addition to the msn search I have also implemented a google site search on my web site. The MSN site search is faster and more reliable than the google site search. It is also much easier to setup. The google api requires you to download a wdsl and then compile that on the server. You can then access the search via an object. Though a good exercise it seems a bit more complicated than need be when compared to the elegance of a simple RSS feed.

That being said there are some major advantages to the web service approach. Since msn makes its search results public there is really no way for them to authenticate or track where the results are being used. They really can't tell the difference between someone clicking the button, reading the results in their mail client or using it to search their own site using the script above.

Also though it may be difficult for Microsoft to track where its feed is being used the licensing information within the RSS file specifically states that the results are not to be used for commercial purposes. As I understand to google api is free for all for up to 1,000 searches per day. So if you are building a commercial web site I would recommend using the google search api, but if you are just looking to implement a great quick search on your personal web site the msn site search is a great choice. If you do decide to use this script on your web site please post a link so I can take a look.

note: This article has been updated please see Search Your Site Using Windows Live Search (Part II)




Comments For This Article:

Wow! Cool script. I wish I could have used it on my site, but MSN Search doesn't update it too often. Hope I can find a use for it somewhere :) -Stephen Stakey Microsoft MVP -- MSN Encarta

posted on: 8/16/2005 8:24:17 PM by srstakey


This is great! Cool. I'm just wondering, what is __VIEWSTATE doing in URL? What is it for?

posted on: 8/31/2005 6:27:46 PM by Karol


Does this only work on public domain websites? Can it be used for an Intranet website? How would that work?

posted on: 9/27/2005 10:28:22 AM by Andy


__VIEWSTATE remembers what you typed into the search box as you go through the records. It can only be used by a website that is spidered by msn search. Thanks all. -jason

posted on: 10/3/2005 5:21:03 PM by Jason


Nice subject

posted on: 11/26/2005 12:00:07 AM by Issa


Do you have a sample of this code in C#?

posted on: 11/29/2005 6:50:47 PM by Arthur


no but i can write it. I have to update this so it pages correctly in .net 2.0 anyway. I will post a c# version. I will not be able to get to it before the weekend. -jason

posted on: 11/30/2005 3:29:13 AM by jason


Ok. Thanks. That is my current problem. I'm having this error:

posted on: 12/1/2005 7:53:07 PM by Arthur


Hi all please check out the new version of this project.

posted on: 2/18/2008 1:11:13 AM by Jason


Post A Comment:

  Your Name:


  Your Comment:

  Please Enter The Captcha Image: