Upload
damir-dobric
View
3.012
Download
1
Embed Size (px)
DESCRIPTION
Web development with ASP.NET Web API by Microsoft MVPs Damir Dobric and Bahrudin Hrnjica
Citation preview
Windows Azure
Custom Software Development MobileMiddleware
Web Development with WCF Web API ASP.NET Web API
Dipl.-Ing Damir Dobric
Lead Architectdaenet
Microsoft Most Valuable Professional
Email: [email protected]: bhrnjica.net
Microsoft vTSP – GermanyTechnology Advisor in Business Platform Division – Microsoft Corp.Microsoft Most Valuable Professional
Email: [email protected]: [email protected]
Dipl.-Ing Bahrudin Hrnjica
Senior Software Developerdaenet
Windows Azure
Custom Software Development MobileMiddleware
Agenda
• From WCF to Asp.NET Web API• Protocols in Web• Routing in Web API• HttpClient
– Formatters and Custom Formatters– Filters and Custom Filters
• Demos through every subtitles• Recap• Q/A
Windows Azure
Custom Software Development MobileMiddleware
ASP.NET Web API
Windows Azure
Custom Software Development MobileMiddleware
From WCF to ASP.NET Web API• First apear as WCF Web API• HTTP related• WCF -wider that HTTP (TCP, Named Pipe,
WinService, etc)• ASP.NET is closer technology• Can be treated as part of .NET vNext
Windows Azure
Custom Software Development MobileMiddleware
ASP.NET Web API
• Modern HTTP programming model• HTTP related• Full support for ASP.NET Routing• Content negotiation and custom formatters• Model binding and validation• Filters• Query composition• Code-based configuration• Self host
Windows Azure
Custom Software Development MobileMiddleware
Demo: Simple ASP.NET Web API App
Integration in MVC 4
Invoke operation
from browser
Add opeartion with params
GET, POST, PUT, DELETE
Windows Azure
Custom Software Development MobileMiddleware
Web Protocols
• SOAP• REST• SOAP Contract vs. Contract based on
document Three (REST)• Formatting (HTML, OData, etc.)
Windows Azure
Custom Software Development MobileMiddleware
Routing
• Web API uses HTTP methods• MVC-style Routing is still avaliable• Controller handles HTTP requests• Set routing to
HttpSelfHostConfiguration
Windows Azure
Custom Software Development MobileMiddleware
Routing
HTTP Method URI Path Action Parameter
GET api/products GetAllProducts (none)
GET api/products/4 GetProductById 4
DELETE api/products/4 DeleteProduct 4
POST api/products (no match) -
Windows Azure
Custom Software Development MobileMiddleware
Demo: Simple routing
Get with and without params
Put and Post sample
Name routing resolution
Sample delete
method
Windows Azure
Custom Software Development MobileMiddleware
HttpClient
Windows Azure
Custom Software Development MobileMiddleware
HttpClient
• Modern HttpCLient for .NET• NuGet packages– System.Net.System– System.Net.Http.Formatting– System.Json
• Hady when using in JavaScript code
Windows Azure
Custom Software Development MobileMiddleware
Formatters
• XML• JSON• Custom
Windows Azure
Custom Software Development MobileMiddleware
Demo: Using Formatters
XML Formatter
JSON formatter
vCards Custom
Formatter implementati
on
vCad Formatter
Windows Azure
Custom Software Development MobileMiddleware
Filters
• Custom Validation Filter• Custom Error Filter
Windows Azure
Custom Software Development MobileMiddleware
Demo: Using Filters
Filters sample Custom Filters
Custom error filters
Custoim validation
Windows Azure
Custom Software Development MobileMiddleware
RECAP
Windows Azure
Custom Software Development MobileMiddleware
Recap
• New way of building REST based web application
• Easy of using• Built on top of APS.NET MVC• Routing convention• HTTP Standard method GET, POST, PUT,
DELETE• Still support MVC routing methods• Different Formatters: XML, JSON, Custom• Different Filters
Windows Azure
Custom Software Development MobileMiddleware
Contact• More info about Web API
– http://asp.net/web-api - official page– http://blogs.msdn.com/b/henrikn/
• Blogs:– Damir‘s Blog: http://developers.de/blogs/damir_dobric/default.aspx– Bahrudin‘s Blog: http://bhrnjica.net
• Emails:– [email protected]– bahrudin,[email protected]