Introduction
This article explains the GET method in Web API 2. A web uses this method when we want to get something from the Web API. Here we use the Get method for reading the student details from the controller by the JavaScript and jQuery.
Now let's see the examples of the GET HTTP method.
Step 1
- Start Visual Studio 2013.
- From the Start Window select "New Project".
- Select "Installed" -> "Templates" -> "Visual C#" -> "Web" and select "ASP.NET Web Application".

- Click on the "OK" button.

- From the ASP.Net project window select "Web API".
- Click on the "Create Project" button.
Step 2
Add a model class:
- In the "Solution Explorer".
- Right-click on the Model Folder.
- Select "Add" -> "Class".
- Select "Installed" -> "Visual C#" and select class.

- Click on the "OK" button.
Add some code as in the following:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace GetMethodAPI.Models
- {
- public class Student
- {
- public int ID { get; set; }
- public string Name { get; set; }
- }
- }
Step 3
In the "Solution Explorer".
Right-click on the "Controller" folder.
- Select the "Controller" and from the controller window select "Common" -> "Web API".

- Select the "Web API2 Empty Controller" and click on the "Add" button.

- Change the name and click on the "Add" button.
Add the following code:



Comments
Join the conversation! Your thoughts help the community grow.