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.
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.
After providing the required details Click Continue.
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.
In My Account Section user can see about their Account information, List of Applications, Account Data and Account Key.
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.
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.
By following the above link you will see the following window.
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.
Following screen will be in front of you, which is a Thank You page for subscribing the API.
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.
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.
3. To build the code file you need to add reference to the following library.
You can add the reference by Right Clicking on Solution Explorer >Add Reference > Select .Net Tab.
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.