This presentation provides overview of new asp.net web api, comparing with MVC, and go through features of web api such as Content Negotiation, Queryable, Html help page, and more.
4. MVC vs WebApi
MVC WebApi
Model View
HTML
Model
Content
Negotiatio
n
Result
5. Content Negotiation
- Return format from request
- Get format from header, querystring,
extension, and more
- Built-in support for json, xml, bson
- You can create your own format ie. csv,
atom, protobuf.net
6. Content Negotiation 2
- Accept various input formats from request
- Built-in support for url encoded, json, xml,
bson
7. Queryable / OData
- Query from result set
- $top, $skip, $select, $orderby, $inlinecount,
$filter, $expand
- Query operation is done from database
8. Auto resolve action
- Match action without explicitly define
- Your url will comply to REST convention
GET /api/product/{id} for retrieve
POST /api/product for insert
PUT /api/product/{id} for update
DELETE /api/product/{id} for delete
9. Exception
- Exception is data not html
- Http Status Code will tell you error category
400: wrong parameter
401: not login
403: no authorize
404: not found
...
10. Html Help Page
- Create help pages instantly
- Utilize xml comments from your codes
11. Control over Http Pipeline
- Alter Http Request and Response
- Control over content
- Push stream content
- Byte range content
- or your own
12. More!!!
- CORS support (cross domain request)
- Support Batch operation
- Not need to host on IIS, WebApi is portable