What is Web API? When should we use in our projects?
- Get link
- Google+
- Other Apps
Introduction to Web API
Web API is the Microsoft open source technology for developing REST services based on HTTP protocol. ASP.Net Web API is a framework for building, consuming HTTP based service. The advantage of Web API is that it can be consumed by a wide range of clients like a web browser and mobile applications.ASP.Net Web API was released with ASP.Net MVC 4. Web API can be used with MVC or normal ASP.Net forms.
Few Web APIs are Google MAP, Facebook, Twitter, Amazon.
Remember HTTP != REST. It means ASP.Net Web API is not an architectural style.
ASP.Net Web API uses common HTTP verbs:
You can use ASP.Net web API with MVC and ASP.Net web forms as well.
ASP.Net Web API doesn't stick to any architectural style. A RESTful service can be built on top of ASP.Net web API.
Now you might have a question in your mind.
We have WCF already running in the market then why ASP.Net Web API?
We can also develop HTTP based services and can develop RESTful services using WCF.
There could be multiple reasons to use WCF over ASP.Net Web API
1. If you have SOAP-based service then go to WCF service.
2. If you are limited to .NET 3.5 version then go for WCF service.
One major advantage of ASP.Net Web API over WCF services is that to implement WCF services we must do lots of configuration to complete the task whereas in ASP.Net Web API it requires zero configuration to do the same task.
Please have a look at below code:
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
public string Get(int id)
{
return "value";
}
// POST api/values
public void Post([FromBody]string value)
{
}
// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/values/5
public void Delete(int id)
{
}
|
Why Web API?
In earlier days we had specific clients like a web browser. But nowadays we have various clients like web browser, mobile application, and other handheld device applications. These devices contain many apps for different purposes.Suppose you have created a service and you like to expose the service to a web browser and all latest apps in handheld devices. Here you can create multiple services for each client which do not make any sense in this era. Here Web API comes into the picture.
Below image explains a Web API in a simple way.

ASP.Net Web API supports JSON as well as XML data exchange format.

ASP.Net Web API supports JSON as well as XML data exchange format.
When to go for ASP.Net Web API?
If you have a web service and you don't need SOAP then go for Web API.
It is Lightweight and good for a slow connection to the 2G mobile internet.
No configuration needed like WCF services.
Supports clean URL
ASP.Net Web API routing is similar to MVC routing.
So what is Web API routing?
Web API routing is the way to route the incoming request
System.net.Http
System.Web.Http
System.Web.Http.WebHost
Supports clean URL
ASP.Net Web API Routing
ASP.Net Web API routing is similar to MVC routing.
So what is Web API routing?
Web API routing is the way to route the incoming request
Assembly used in ASP.Net Web API
System.net.Http
System.Web.Http
System.Web.Http.WebHost
Summary -
- A framework to create HTTP based services
- It supports HTTP verbs - GET, POST, PUT DELETE
- ASP.Net Web API can be consumed by a wide range of clients like web browsers, mobile apps and more.
- ASP.Net uses HTTP as application protocol.
- It supports IIS hosting and self-hosting
- By default ASP.Net Web API returns JSON data.
- It supports ASP.Net routing
- ASP.Net Web API implementation can be done with ASP.Net web forms, MVC, and ASP.Net Core
Next Blog - How to create a basic ASP.Net Web API
- Get link
- Google+
- Other Apps
Popular
What is MicroService? A modern approach to develop software applications
Before describing MicroServices we should first understand distributed technologies we already have in the industry. Prior to MicroServices, we have already Web Services, WCF Service and latest one from Microsoft i.e. ASP.Net Web API. Then Why MicroService Architecture?
You may read about all these distributed technologies in details in my earlier blog.
You may read about all these distributed technologies in details in my earlier blog.
CAML Query Tutorial for SharePoint 2013 and 2010 - A Complete tutorial guide
CAML Query is one of the most important topics in SharePoint. CAML Query is the way for querying items from SharePoint objects like List and Library. This blog is helpful in SharePoint 2010 development as well as in SharePoint 2013 development.
How to consume RESTful APi from server side code - C#
What's new in C# 6.0 language - All new features of C# 6.0 for developers
In the previous blog, we have seen
Introduction to .NET Core - Basic Introduction with Visual Studio 2015 and 2017. Other important blogs I wrote - What is MicroServices?Angular JS for ASP.Net Developer.
In this blog, we will learn new features of C# 6.0. C# 6.0 - An another version of C# released in the year 2015. C# 6 provides numerous new features but I will write about those features which I have explored and which are useful for a developer. You must be curious to know What's new in C# 6.0? Let's start.
Introduction to .NET Core - Basic Introduction with Visual Studio 2015 and 2017. Other important blogs I wrote - What is MicroServices?Angular JS for ASP.Net Developer.
In this blog, we will learn new features of C# 6.0. C# 6.0 - An another version of C# released in the year 2015. C# 6 provides numerous new features but I will write about those features which I have explored and which are useful for a developer. You must be curious to know What's new in C# 6.0? Let's start.
Introduction to .NET Core - Basic Introduction with Visual Studio 2015 and 2017
Till now website/application developed using .net framework can be hosted only on windows platform. So, your application is bounded with windows OS. What if someone wants to deploy .net framework based application on Linux or Mac, earlier there was no solution but now it can be achieved using.NET Core. So let's start by introducing.NET Core.
All about SharePoint 2010 Content Type Hub - SharePoint 2010 Tutorial
Top 20 ASP.Net Web API Interview Questions and Answers
In the previous blog, I wrote about What is ASP.Net Web API? You may also like ASP.Net Web API Tutorial
If you are interested in .Net Core then you may go for .Net Core Tutorial.
In this blog, I have collected interview questions and answers of ASP.Net Web API.
If you are interested in .Net Core then you may go for .Net Core Tutorial.
In this blog, I have collected interview questions and answers of ASP.Net Web API.
SharePoint Interview Questions and Answers
If you have landed to this page it means you are searching for SharePoint Interview Questions and answers, right? You are at right place. In this blog, I have collected important SharePoint interview questions and answers.
Candidate having good knowledge of SharePoint will shine like a star in IT industry. So, it is very important to collect more and more SharePoint interview Questions and Answers to qualify SharePoint interview. Below are few SharePoint questions and answers which are very important and most of them were asked in an interview in IT Companies.
Candidate having good knowledge of SharePoint will shine like a star in IT industry. So, it is very important to collect more and more SharePoint interview Questions and Answers to qualify SharePoint interview. Below are few SharePoint questions and answers which are very important and most of them were asked in an interview in IT Companies.
Getting started with Microsoft Azure
If you are new to Microsoft Azure, then please read my earlier blog on Cloud Computing and Microsoft Azure introduction.
In this blog, I will explain how to create resources in Azure Dashboard and will show you screenshots. This will be a totally new experience for me as well because I am also new to Cloud Computing and wanted to share my experience through my blog.
In this blog, I will explain how to create resources in Azure Dashboard and will show you screenshots. This will be a totally new experience for me as well because I am also new to Cloud Computing and wanted to share my experience through my blog.
ASP.Net Web API Security
If you are new to ASP.Net Web API then please start from the beginning level. What is ASP.Net Web API? In the previous blog, I wrote about Routing in Web API. You may also like .Net Core Introduction and MicroService Architecture.
I have also explained, How to create a secure Web API? in my earlier blog.
In this blog, let's discuss the Web API security in details.
I have also explained, How to create a secure Web API? in my earlier blog.
In this blog, let's discuss the Web API security in details.
Comments
Post a Comment
Dear Readers, Please post your valuable feedback in the comment section if you like this blog or if you have any suggestions. I would love to hear the same from you. Thanks