Web Api vs MVC

13

Click here to load reader

description

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.

Transcript of Web Api vs MVC

Page 1: Web Api vs MVC

WebApi vs MVC

Page 2: Web Api vs MVC

About

Chaowlert C.

Production WebApi experience on- Samsung Gift- AIS Privilege- InSing (SingTel Social)

Page 3: Web Api vs MVC

Overview

WebApi- Provide REST service- Backend for Mobile Device

- Backend for JavaScript

MVC- Provide Web Page

Page 4: Web Api vs MVC

MVC vs WebApi

MVC WebApi

Model View

HTML

ModelContent

Negotiation

Result

Page 5: Web Api vs MVC

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

Page 6: Web Api vs MVC

Content Negotiation 2

- Accept various input formats from request

- Built-in support for url encoded, json, xml, bson

Page 7: Web Api vs MVC

Queryable / OData

- Query from result set- $top, $skip, $select, $orderby, $inlinecount, $filter, $expand

- Query operation is done from database

Page 8: Web Api vs MVC

Auto resolve action

- Match action without explicitly define- Your url will comply to REST conventionGET /api/product/{id} for retrievePOST /api/product for insertPUT /api/product/{id} for updateDELETE /api/product/{id} for delete

Page 9: Web Api vs MVC

Exception

- Exception is data not html- Http Status Code will tell you error category

400: wrong parameter401: not login403: no authorize404: not found...

Page 10: Web Api vs MVC

Html Help Page

- Create help pages instantly- Utilize xml comments from your codes

Page 11: Web Api vs MVC

Control over Http Pipeline

- Alter Http Request and Response- Control over content- Push stream content- Byte range content- or your own

Page 12: Web Api vs MVC

More!!!

- CORS support (cross domain request)- Support Batch operation- Not need to host on IIS, WebApi is portable

Page 13: Web Api vs MVC

Thank you

This event sponsored by

And we are hiring!