19
Windows Azure Custom Software Developmen t Mobile Middlewar e Web Development with WCF Web API ASP.NET Web API Dipl.-Ing Damir Dobric Lead Architect daenet Microsoft Most Valuable Professional Email: [email protected] Blog: bhrnjica.net Microsoft vTSP – Germany Technology Advisor in Business Platform Division – Microsoft Corp. Microsoft Most Valuable Professional Email: [email protected] Email: [email protected] Dipl.-Ing Bahrudin Hrnjica Senior Software Developer daenet

Web development with ASP.NET Web API

Embed Size (px)

DESCRIPTION

Web development with ASP.NET Web API by Microsoft MVPs Damir Dobric and Bahrudin Hrnjica

Citation preview

Page 1: Web development with ASP.NET Web API

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

Page 2: Web development with ASP.NET Web API

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

Page 3: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

ASP.NET Web API

Page 4: Web development with 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

Page 5: Web development with ASP.NET Web API

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

Page 6: Web development with ASP.NET Web API

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

Page 7: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

Web Protocols

• SOAP• REST• SOAP Contract vs. Contract based on

document Three (REST)• Formatting (HTML, OData, etc.)

Page 8: Web development with ASP.NET Web API

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

Page 9: Web development with ASP.NET Web API

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) -

Page 10: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

Demo: Simple routing

Get with and without params

Put and Post sample

Name routing resolution

Sample delete

method

Page 11: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

HttpClient

Page 12: Web development with ASP.NET Web API

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

Page 13: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

Formatters

• XML• JSON• Custom

Page 14: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

Demo: Using Formatters

XML Formatter

JSON formatter

vCards Custom

Formatter implementati

on

vCad Formatter

Page 15: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

Filters

• Custom Validation Filter• Custom Error Filter

Page 16: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

Demo: Using Filters

Filters sample Custom Filters

Custom error filters

Custoim validation

Page 17: Web development with ASP.NET Web API

Windows Azure

Custom Software Development MobileMiddleware

RECAP

Page 18: Web development with ASP.NET Web API

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

Page 19: Web development with ASP.NET Web API

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]