Reputation: 1
I have read about the asp.net Web API ,, but i am not sure if i understand the concept behind the Web API tool. now let say that i have defined a Controller that is derived from the APIController, and i can call this Controller using URL , and then the Controller will return JSON result to the client,,,
so does this means that the APIController inside my asp.net MVC web application is exposed as a RESTfull web service? BR
Upvotes: 0
Views: 274
Reputation: 12705
i just want to add to Anders
REST stands for Representational state transfer
so basically in architecture you choose a resource
like http://www.example.com/USER
and you instruct the server to do operations on the resource. Specified by the type of HTTP
request being sent
going by what web api comes out of the box
POST
- add a new user
PUT
- edits an existing users info
GET
- simply retrives user(s) info
DELETE
- deletes users info
and this is REST
The type of data being sent or recived (JSON
or XML
). isnt a part of rest specifications. also you can decide incase of asp.net web api data is returned and sent in what format by using
Accept
and Content-Type
headers with your request
Upvotes: 1
Reputation: 8397
Whether or not your API is considered 'RESTfull' is a question of design, not a question of which libraries/project templates are used. Remember that the whole point of an API is to expose a simple programming interface - how it's implemented behind the scenes isn't important in that regard.
However, the WebAPI project template does lend itself well to designing a restfull service due to its built in design principles.
The basic idea behind a REST API is:
It's not much different from designing a REST API using basic MVC Controller/Actions, WebAPI just makes it a bit easier.
Here's a nice video series: http://www.asp.net/web-api/videos/getting-started/your-first-web-api
Upvotes: 2
Reputation: 1529
Well Apicontroller totaly different from mvc Controller, it comes from Wcf WebApi but made very similar to classic asp.net controllers to developers. The main point is to speed up making restfull services.
So you just assign one more route as always, making some controller than takes querystring and body json(as default) and autoconverts in to Poco classes and returns you another Poco classes serialized to jsion automatically.
Upvotes: 0