In this article you will learn how to integrate the Bing search in your ASP.NET application. The Bing Developer Center exposes a few APIs for Bing search which can be used to integrate it in your .NET framework application. Our applications can make requests with the required parameters to the Bing search APIs and get the search results back.
The Bing API’s are exposed through HTTP and can support the message formats below.
What is the use?
For most of the readers the first thought to cross their minds is, what would be the use of integrating Bing Search into our application. The obvious answer would be, so the user doesn’t have to leave your web site in case he needs to search the web.
Token to access the Bing Search API – AppId
In order to use the Bing APIs you need to have a valid AppId. You can get the AppId by going to the Microsoft Developer Center and follow the steps below.
- Sign in using your Windows Live Id. If you don’t have one then please go ahead and create it.
- Click on the link “Create new AppId”, which will take you to a form. Fill in the form and click on Agree. Fig 1.0 shows the screen shot of the AppId form.
- The AppId will be displayed on the page. Copy it and have it for the usage in our application.
Implementing Bing Search in an ASP.NET application
Let us create an ASP.NET application and then implement the Bing search in it. I will be using the Bing search API for SOAP in our demo application.
Using Microsoft Visual Studio 2010 create an ASP.NET Web Application and name it as
BingSearchAPIDemo. Now open the
web.config file and add an
appSettings value for the AppId as shown below.
<add key=”BingAppId” value=”XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”/>
Add a webform named SearchPage.aspx. Fig 2.0 is the .aspx designer code.