Introduction

This article explains you how to use the Google Search API in the ASP.NET Web API. Here we use a variable "sitesearch" that handles the Google Search engine. If we have the null value of the variable "sitesearch" then it searches the entire web and if we mention any site as the value of "sitesearch" then it searches only that site.

Google API

Let us see the procedure to use the Google API in the Web API.

  1. First we create a Web API Application.
  1. Now we add some code in the "Index.cshtml" file for using the Google API. This file exists:
  1. Now to execute the application. Press "F5" and check that it is working. The output will be as in the following:

    google3.jpg

    If we choose "Search on Web" then the output will be:

    google6.jpg
    If we choose the site "c-sharpcorner.com" then the output will be:

    google5.jpg

    If we choose the site "msdn.microsoft.com" then the output will be:

    google4.jpg