English
  • English
  • हिन्दी
  • বাংলা
  • తెలుగు
  • தமிழ்
  • ಕನ್ನಡ
  • मराठी
  • മലയാളം
  • ଓଡିଆ
  • ગુજરાતી
  • ਪੰਜਾਬੀ
  • অসমীয়া
  • اردو

How to create a web API with ASP.NET

Web API Using ASP.NET

What is Web API?

A web API is an Application programming language that is used to generate a communication between software components. ASP.NET is a framework that makes easy to build and reaches a wide range of clients, including browser and mobile devices. Through ASP. NET, web API can enable interaction of different devices from the same database.

Diagram

Diagram
Diagram

How Web API works?

• Web API is used to access the service data, many mobile applications and the other devices.

• It helps to create Restful (Representational State Transfer) web services.

• IT used to create an HTTP web services that supports XML, JSON and other data formats.

• Initially, it is used to build web services which are lightweight, scalable and conceivable.

Steps for creating web API

1. We will start with the Visual studio. Open visual studio and open new project. Select Menu >> Web >> ASP.NET web application. Give project name and click OK

2. After opening the template window, select WEB API, Some messages will appeared at the right side. Now, click on OK button.

3. Now, our project will open. Go to the controller where we can see “ValueController.cs” This is the main class for Web API. It is created by default.

Create a new controller with a different name. Select Controller >> Add >> Controller as below.Select “Web API Controller – Empty“ and click on “Add” button.

4. Now, create a method in the controller, built the application and run. We will use “get()” method for it. Below is the code.

5. We need to run API  URL format. Fer Example, We create Url format in MVC using “ RoutConfig” & “RegidterRoutes” class and static methods. Same as in Web API we will use “ WebApiConfig” & “Register” static methods.

6. Now built a project and run it in above mentioned format. As we have created a Demo controller, it will run it in following URL “http://localhost:53027/api/Demo”

It will give you the output in following manner.

Above article can help new learners, students and fresher about an integration of Web API. To learn more you can visit http://www.concettolabs.com/blog/

This is a YourStory community post, written by one of our readers.The images and content in this post belong to their respective owners. If you feel that any content posted here is a violation of your copyright, please write to us at mystory@yourstory.com and we will take it down. There has been no commercial exchange by YourStory for the publication of this article.
We would like to introduce ourselves as a prominent IT firm – Concetto Labs Pvt. Ltd. – established in Ahmedabad since 2010 Concetto Labs is a leading solution provider for Internet based applications and Mobile Applications. The Company has been promoted by some highly experienced Professionals dedicated to provide total IT solutions under one roof. Concetto Labs is a set up that has a group of professional personnel that are in sync with all new IT developments taking place and has the ability to utilize this knowledge to create software that adapts to the changing IT scenario. Concetto Labs provides high quality mobile application development as well as competitive website development through the use of latest technologies. We provide a one stop solution for all IT related services.

Related Stories