I have a little understanding on REST API. As per my knowledge it is used to work with HTTP services(GET POST PUT DELETE).
When i add a webapi controller it provides me some basic methods like :
public class Default1Controller : ApiController
{
// GET api/default1
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/default1/5
public string Get(int id)
{
return "value";
}
// POST api/default1
public void Post([FromBody]string value)
{
}
// PUT api/default1/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/default1/5
public void Delete(int id)
{
}
}
So my question is what's the difference between Web API and REST API?
As from rest definition the above code is REST based so what's a normal Web API in MVC? I'm a bit confused as some people says do you use web api with REST?
Kindly provide a better understanding of the both.
This question is related to
c#
rest
api
asp.net-web-api
model-view-controller
ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
REST
RESTs sweet spot is when you are exposing a public API over the internet to handle CRUD operations on data. REST is focused on accessing named resources through a single consistent interface.
SOAP
SOAP brings it’s own protocol and focuses on exposing pieces of application logic (not data) as services. SOAP exposes operations. SOAP is focused on accessing named operations, each implement some business logic through different interfaces.
Though SOAP is commonly referred to as “web services” this is a misnomer. SOAP has very little if anything to do with the Web. REST provides true “Web services” based on URIs and HTTP.
Reference: http://spf13.com/post/soap-vs-rest
And finally: What they could be referring to is REST vs. RPC See this: http://encosia.com/rest-vs-rpc-in-asp-net-web-api-who-cares-it-does-both/
Source: Stackoverflow.com