Articles → ASP .NET WEB API → Introduction To Web API

Introduction To Web API






What Is Web API





Create Your First Asp.Net Web API




  1. Open visual studio
  2. Click on File - New Project. A window appears as shown in the following figure
  3. Picture showing selecting the new ASP.NET web application template
    Click to Enlarge



  4. Another window appears as shown in the following figure
  5. Picture showing selecting the Web API as project type
    Click to Enlarge





Folder Structure




Picture showing the project structure of the asp.net web api project
Click to Enlarge




Adding Controller




  1. Right click on the controller folder and click on Add – Controller..
  2. Picture showing adding a new controller in the web api project
    Click to Enlarge

  3. A window appears as shown in the following figure
  4. Picture showing a window to select the type of controller in web api project
    Click to Enlarge



  5. In the next window, enter the controller name and click on ‘Add’ (See the following figure).
  6. Picture showing a window to add the controller name
    Click to Enlarge





Add Code In Controller




public class TestController: ApiController {
	public string Get() {
		return "value";
	}
}





Output




Picture showing the different parts of the URL of the web API
Click to Enlarge





Picture showing the output of your first asp.net web api program
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, January 17, 2016

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250