---
title: "Integrate Bing Search API in ASP.NET Web Form"  
description: "The Bing Application Programming Interface (API) enables developers to programmatically submit queries to and retrieve results from the Bing Search En"  
author: "Anonymous User"  
published: 2012-09-08  
updated: 2020-05-20  
canonical: https://www.mindstick.com/articles/995/integrate-bing-search-api-in-asp-dot-net-web-form  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 10 minutes  

---

# 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](https://www.mindstick.com/services/search-engine-optimization). 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](https://www.mindstick.com/forum/158577/what-is-the-significance-of-the-base-class-library-bcl-in-the-dot-net-framework) 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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/2e1954cf-faf5-4a83-9c33-7507110e9093.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/31a20fc5-4f11-43f7-b1f6-eb51af1cc3d9.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/80f1cda0-2e6a-4ad4-b730-62e426c70f43.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/2ee408f8-4e30-43a6-8b5d-d6124bed3a81.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/8b06e19b-c1c8-4920-b471-0806cd5ac4bb.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/fe622dc6-5bc3-4d40-8fd6-383d2e99c280.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/152c5051-e552-4b48-819f-dfa37603a173.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/6ad3f63c-8581-4a48-bd66-eb1b512f2202.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/b464150d-532d-4c42-b140-3a948c5d2a9b.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/5a551170-053b-462a-9bca-e7e9904e9fb3.png)

Till Now you have finished all the steps that are [needs to be followed](https://www.mindstick.com/interview/2669/what-are-the-rules-method-access-permission-and-exception-that-needs-to-be-followed-during-method-overloading-and-overriding) for

Registering on Windows Azure Marketplace, Subscribing Bing Search API and

Downloading the .Net C# Class [Library File](https://www.mindstick.com/interview/2537/is-jquery-is-a-javascript-or-json-library-file). Now we are ready to use it in our

program.

1. Open [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) 2010 >File >New >Website >Under Template Section Choose ASP.NET Empty [Web Site](https://www.mindstick.com/articles/12285/the-finest-web-site-design-trends-you-may-expect-in-2017), 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](https://www.mindstick.com/forum/156583/best-way-to-link-bootstrap-file-in-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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/e3f1fc71-d774-4370-95cf-188614fccb3f.png)

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](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/75bc4894-b43c-4b97-a5fb-dcd34233c342.png)

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](https://answers.mindstick.com/qa/92898/how-to-create-a-web-page-using-bootstrap-4) you have added.

![Integrate Bing Search API in ASP.NET Web Form](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/8162e63b-09fe-43fe-b6fc-a0298157b0e1.png)

\

In above UI, I have taken a TextBox Control for Entering Search Term into it, a

\

Button Control and a GridView Control to show the search result.\

\

In GridView I have added three Template Control i.e., a Label Control for Displaying

\

the Title, a Hyperlink Control which will enable user to Navigate to the Page and

\

again a Label Control to show the description of the site. I have bind all these

\

Controls to the Data Source using

\

'<%# Bind("<ColumnName>") %>'

##### Here is the code snippet that I have written for the Default.aspx page.

```
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <table style="width:100%;">
            <tr>
                <td align="center" bgcolor="#99CCFF" colspan="2">
                    <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Georgia"
                        Text="Integrate Bing Search API into ASP.Net application"></asp:Label>
                </td>
            </tr>
            <tr>
                <td width="80px">
                    &nbsp;</td>
                <td height="40px">
                    <asp:TextBox ID="txtSearch" runat="server" Height="30px" Width="639px"></asp:TextBox>
                    <asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Names="Georgia"
                        Height="30px" Text="Search" Width="65px" onclick="Button1_Click" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <hr />
                    </td>
            </tr>
            <tr>
                <td style="border-color: #999999">&nbsp;</td>
                <td style="border-color: #999999">
                    <asp:GridView ID="GridViewSearchResult" runat="server"
                        AutoGenerateColumns="false" ShowHeader="false" Width="712px"
                        BorderColor="White">
                    <Columns>
                    <asp:TemplateField>
 
                        <ItemTemplate>
                            <asp:Label ID="lblTitle" runat="server" Text='<%# Bind("Title") %>'
                                Font-Size="Large"></asp:Label>
                            <br />
                            <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#Bind("Url") %>'><%#Eval("Url") %></asp:HyperLink>
                            <br />
                            <asp:Label ID="lblDescription" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                            <br />
                            <br />
                        </ItemTemplate>
 
                    </asp:TemplateField>
                    </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>
   
    </div>
    </form>
</body>
</html> 
```

5. Now, Switch to Default.aspx.cs file.

Add Following Code for Button Click Event Handler.

```
//Add the namespace "Using Bing;"
    protected void Button1_Click(object sender, EventArgs e)
    {
        var objBing = new Bing.BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/Search"));
        //Replace this Account Key with you Account Key
        var accountKey = "EMdPzpSl/qTbvz6/ScfE5sFLzuxNfU/crNSmIYjQDes=";
        //Passing the Credintial
        objBing.Credentials = new System.Net.NetworkCredential(accountKey, accountKey);
        //Following Line is used to get the Search Result as DataSource.
        var webResult = objBing.Web(txtSearch.Text.ToString(),null,null,null,null,null,null,null);
        //Binding the Resultant DataSource to the GridView
        GridViewSearchResult.DataSource = webResult;
        GridViewSearchResult.DataBind();
    }
```

Now run you project. Following Window will appear in front of you.

![Integrate Bing Search API in ASP.NET Web Form](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/e82b05ef-3dda-4d22-9005-d0019419c7fa.png)

Enter the [Search Term](https://answers.mindstick.com/qa/106575/what-is-the-adwords-search-term-report) into the TextBox and Click on [Search Button](https://answers.mindstick.com/qa/34597/what-is-site-search-button) to get the Result.

Result will be shown as follows:

![Integrate Bing Search API in ASP.NET Web Form](https://www.mindstick.com/mindstickarticle/7ce690e8-927a-4c9f-884a-1a11f576f233/images/4a2f02dc-5fa5-48f0-a10e-71106b27f2c1.png)

In this article I have described everything in very simple manner, also tried to go through the every terms and concept for Integrating Bing Search Api in our application. Screenshots for every step are provided to make is simple to be go through the every terms and concept for Integrating Bing Search Api in our application. Screenshots for every step are provided to make is simple to be used. Using these steps you can easily Integrate Bing Search API you can easily give a useful functionality for Searching Stuffs in your application. I hope this will be a good article for you.

\

---

Original Source: https://www.mindstick.com/articles/995/integrate-bing-search-api-in-asp-dot-net-web-form

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
