ASP.NET MVC Web API

1,851 views

Published on

Brownbag presentation on ASP.NET Web API for MPS Partners and clients, September 2012.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,851
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
30
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Bolt-on APIs, MVC-conventions throughout your front end
  • ASP.NET MVC Web API

    1. 1. Andy Badera, Microsoft Evangelist Solution & Platform Evangelism MPS Partners
    2. 2.  What is it? What can it do for me? How is it different from MVC?
    3. 3.  Simplicity MVC-like routing/naming conventions Rapid prototyping/iterative dev Media type formatters Easy (de)serialization Easy PATCH support
    4. 4.  Light on OOTB security (can be added) Potential for confusion across HTTP routes, naming conventions and declarations Single primitive value passable in body Cannot pass naked primitives as JSON
    5. 5.  Web API version of MVC Routes Configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: “api/{controller}/{id}”, defaults: new { id = RouteParameter.Optional });
    6. 6.  GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS “All”, “By*” GetEnabledUsers, [verb]EnabledUsers: config.Routes.MapHttpRoute( name: "EnabledUsersRoute", routeTemplate: “Users/{someguid}/enabled”); http://host/Users/{someguid}/enabled
    7. 7.  Simple types (primitives, DateTime) default from URI Complex types from body Simple types can be passed in body (x-www- form-urlencoded only) if method parameter is marked with [FromBody]
    8. 8.  Accept header ◦ application/xml ◦ application/json Custom formatters
    9. 9.  JSON.NET (Newtonsoft) shipped as default in RTW DataContractJsonSerializer Can be swapped/substituted Per-type XML Serializers (backwards compatibility)
    10. 10.  VS2010: JSONtoCSharp http://json2csharp.com/ VS2012: Web Essentials, Paste Special JSON Formatter & Validator http://jsonformatter.curiousconcept.com/
    11. 11.  New-ish HTTP verb Partial record modification of existing resource (vs POST full record modification of existing resource) JSON handling is conducive to easy deserialization of partial objects

    ×