Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Overview of ASP.NET Web API Framework

Alexander Beletsky
September 29, 2012
390

Overview of ASP.NET Web API Framework

Alexander Beletsky

September 29, 2012
Tweet

Transcript

  1. @alexbeletsky
    http://beletsky.net
    Overview of
    ASP
    .NET Web API
    Framework

    View Slide

  2. @alexbeletsky
    http://beletsky.net
    @alexbeletsky
    http://beletsky.net
    http://xpinjection.com

    View Slide

  3. @alexbeletsky
    http://beletsky.net
    What's new in ASP.NET 4.5?
    One ASP.NET Framework
    ASP.NET MVC 4 Release
    ASP.NET WebForms Improvements
    ASP.NET Web Pages 2 (Web Matrix)
    SignalR
    ASP.NET Web API (ex. WCF Web API)
    Open Source

    View Slide

  4. @alexbeletsky
    http://beletsky.net
    What's new in ASP.NET 4.5?
    One ASP.NET Framework
    ASP.NET MVC 4 Release
    ASP.NET WebForms Improvements
    ASP.NET Web Pages 2 (Web Matrix)
    SignalR
    ASP.NET Web API (ex. WCF Web API)
    Open Source

    View Slide

  5. @alexbeletsky
    http://beletsky.net
    Early days of API oriented apps
    /GetOrders
    /GetOrders
    /UpdateOrder
    /GetAllDueOrders
    /DeleteOrder.asmx?id=1
    /UpdateOrder.asms?id=1&title=”New”...

    View Slide

  6. @alexbeletsky
    http://beletsky.net
    RPC
    Remote Procedure Call
    The architecture style, where client sends a request
    to remote server and execute specified procedure
    with optional parameters.

    View Slide

  7. @alexbeletsky
    http://beletsky.net
    SOAP, WSDL, UDDI
    WS-*
    Finally considered to be...

    View Slide

  8. @alexbeletsky
    http://beletsky.net
    … evil

    View Slide

  9. @alexbeletsky
    http://beletsky.net
    RESTful based API
    GET /orders
    GET /orders/1
    POST /orders
    PUT /orders/1?title=”New”
    DELETE /orders/1

    View Slide

  10. @alexbeletsky
    http://beletsky.net
    REST
    Representational State Transfer
    The architecture style, where communication
    between client and server relys on HTTP standard
    and uses lightweight mechanisms for transporting
    data

    View Slide

  11. @alexbeletsky
    http://beletsky.net
    REST, JSON, VERBS
    Finally considered to be...

    View Slide

  12. @alexbeletsky
    http://beletsky.net

    View Slide

  13. @alexbeletsky
    http://beletsky.net
    What is ASP.NET Web API?
    Framework for build REST style API services,
    providing best practices and features of REST
    services inside the box.

    View Slide

  14. @alexbeletsky
    http://beletsky.net
    But I got used
    to build REST API with
    ASP.NET MVC?

    View Slide

  15. @alexbeletsky
    http://beletsky.net
    ASP.NET MVC vs. ASP.NET WEB API
    ASP.NET MVC is positioned as page-oriented
    development framework.
    ASP.NET Web API is positioned as api-oriented
    development framework.

    View Slide

  16. @alexbeletsky
    http://beletsky.net
    ASP.NET WEB API
    One service – many
    clients

    View Slide

  17. @alexbeletsky
    http://beletsky.net
    ASP.NET Web API main features
    - Code Scaffolding
    - Content Negotiation
    - MediaTypeFormatters
    - Hypermedia
    - IQueryable & Odata support
    - Self-Documenting API
    - Hosting Options

    View Slide

  18. @alexbeletsky
    http://beletsky.net
    Quick Example: ASP.NET Mobile App

    View Slide

  19. @alexbeletsky
    http://beletsky.net
    Code Scaffolding
    - Scaffolds for Code-First Entity Framework
    - Easy to use
    - Great for quick start and prototyping
    - CRUD from the box

    View Slide

  20. @alexbeletsky
    http://beletsky.net
    Content Negotiation
    - Find best match between client-server
    - Uses HTTP header information
    - “Invisible” for developer
    - JSON, XML from the box

    View Slide

  21. @alexbeletsky
    http://beletsky.net
    Media Type Formatters
    - For support any custom API format
    - Based on async operations
    - BufferedMediaTypeFormatter wraps the
    asynchronous read/write methods inside
    sychronous methods.

    View Slide

  22. @alexbeletsky
    http://beletsky.net
    Hypermedia Support
    - Flexibility of formats
    - HttpResponseMessage class
    - Embrace correct HTTP status codes

    View Slide

  23. @alexbeletsky
    http://beletsky.net
    IQueryable & OData support
    - Paging and sorting from the box
    - OData functions: $top, $order, $skip, $filter

    View Slide

  24. @alexbeletsky
    http://beletsky.net
    Self Documenting API
    - IApiExplorer interface for getting info
    - ApiDescription encapsulates information about
    particual API class
    - Used to generate documentation pages

    View Slide

  25. @alexbeletsky
    http://beletsky.net
    Hosting Options
    - ASP.NET hosting by default
    - Self Hosting (HTTP server in .exe)
    - OWIN, Kayak
    - Azure Roles

    View Slide

  26. @alexbeletsky
    http://beletsky.net
    I need more!

    View Slide

  27. @alexbeletsky
    http://beletsky.net
    Resources
    http://asp.net/web-api
    http://channel9.msdn.com/search?term=web+api
    http://blogs.msdn.com/b/henrikn/
    http://webapibloggers.com/

    View Slide

  28. @alexbeletsky
    http://beletsky.net
    Follow those guys
    @glennblock, @filip_woj,
    @tourismgeek, @frystyk,
    @radenkozec, @benfosterdev

    View Slide

  29. @alexbeletsky
    http://beletsky.net
    Thanks,
    @alexbeletsky

    View Slide