Home > DeveloperSection > Articles > Integrate Bing Search API in ASP.NET Web Form

Integrate Bing Search API in ASP.NET Web Form


ASP.Net ASP.Net 
Ratings:
0 Comment(s)
 40412  View(s)
Rate this:

Integrate Bing Search API in ASP.NET Web Form

What is the Bing Search API?

The Bing Application Programming Interface (API) enables developers to programmatically submit queries to and retrieve results from the Bing Search Engine. Bing also introduces a superior service for developers. It encourages developers to use their Search API into their own application.

Here, I am going to demonstrate you How to Use Bing Search API in our application.

I’ll discuss about to Integrate Bing Search API from very basics (from registering on Windows Azure Marketplace to Using .Net Class Library to the application).

To use Bing Search API, firstly you need to register on Windows Azure Marketplace.

https://datamarket.azure.com

Integrate Bing Search API in ASP.NET Web Form

When you will click on Sign in Link, it will redirect you to Windows Live Id Authentication Page; here provide your Windows Live ID and Password to Continue. Once successfully Logged In, you will further see the Windows Azure Market Place Registration Page as shown below.

Integrate Bing Search API in ASP.NET Web Form

After providing the required details Click Continue.

In the next page, you should accept the terms of use, it is not optional, you must agree to terms and conditions. Scroll down to the page and select the I agree checkbox and click on Register Button.

Integrate Bing Search API in ASP.NET Web Form

Now you are a registered member of Windows Azure market place. You can subscribe to data applications. In order to use BING API in your application, you must obtain your Account Key, in the previous version of Bing you were required an API key, the current version uses Account Key instead.

Once you logged in to the Windows Azure market place, you can see “My Account” in the top menu, from the Top menu; go to “My Account” Section.

Integrate Bing Search API in ASP.NET Web Form

In My Account Section user can see about their Account information, List of Applications, Account Data and Account Key.

Integrate Bing Search API in ASP.NET Web Form

From the My Account section, you can manage your Subscriptions and Account Keys.

Note: Account Keys will be used by your applications to access the subscriptions from the market place.

Click on My Account link, you can see Account Keys in the left menu and then Add an account key or you can use the default Account key available.

Integrate Bing Search API in ASP.NET Web Form

Till now, we have successfully registered with the Windows Azure Marketplace; also we have gone through the different and important section of the user account.

Now, the next step is to Subscribe for the Bing Search API. Bellow is the direct link to Subscribe Bing Search API.

https://datamarket.azure.com/dataset/5ba839f1-12ce-4cce-bf57-a49d98d29a44

By following the above link you will see the following window.

Integrate Bing Search API in ASP.NET Web Form

 The above page provides options to Subscribe for your API on the basis of your requirements (Paid/Free). Here, in my example I am going to use Free Subscription Option.

To Subscribe the API Click on Sign Up Button.

After Clicking on SIGN UP Button, following window will appear. It will show you Terms of Use of the Bing Search Api.

Integrate Bing Search API in ASP.NET Web Form

Read the Terms of Use, Select I Agree Checkbox and Click on SIGN UP Button to move to next step.

Following screen will be in front of you, which is a Thank You page for subscribing the API.

Integrate Bing Search API in ASP.NET Web Form

Don’t forget to notice, I have marked something with Red Circle in Right Upper Side of the Page. This is your Bing Search API Class Library File (.Net C# Class Library), which will be used in program to make it enable to use Bing Search API.

Download and Save the .Net C# Class Library File by simply clicking on it.

Integrate Bing Search API in ASP.NET Web Form

Till Now you have finished all the steps that are needs to be followed for Registering on Windows Azure Marketplace, Subscribing Bing Search API and Downloading the .Net C# Class Library File. Now we are ready to use it in our program.

1.      Open Visual Studio 2010 >File >New >Website >Under Template Section Choose ASP.NET Empty Web Site, Choose Location to save it and Provide name to it. Click OK.

2.      Now, you have to add the Downloaded .Net C# Class Library to your Project. You can do this task by Right Clicking on Solution Explorer > Add Existing Item >Browse the Location of File > Add it in your Project.

 

Here is a Screenshots of the Project Solution Explorer after adding the .Net C# Class Library file to the project.

It will be better if we add the File to the App_Code Folder as follows.

Integrate Bing Search API in ASP.NET Web Form

 

3.      To build the code file you need to add reference to the following library.
System.Data.Services.Client

 

You can add the reference by Right Clicking on Solution Explorer >Add Reference > Select .Net Tab.

Integrate Bing Search API in ASP.NET Web Form

 

4.      Now, add an ASP WEB Form to your project by Right Clicking on Solution Explorer >Add New Item.

Create the Following UI for the Web Page you have added.