Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building HTTP Services with ASP.NET Web API Sayed Ibrahim Hashimi Program Manager Microsoft Corporation DEV309.

Similar presentations


Presentation on theme: "Building HTTP Services with ASP.NET Web API Sayed Ibrahim Hashimi Program Manager Microsoft Corporation DEV309."— Presentation transcript:

1

2 Building HTTP Services with ASP.NET Web API Sayed Ibrahim Hashimi Program Manager Microsoft Corporation DEV309

3

4 Designed for broad reachUses HTTP as an application protocol, not a transport protocol

5

6 Why build Web APIs?

7

8 GET /en/html/dummy.php?name=MyName&married=not+single &male=yes HTTP/1.1 Host: www.explainth.at User-Agent: Mozilla/5.0 (Windows;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11 Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://www.explainth.at/en/misc/httpreq.shtml

9 demo Sayed Ibrahim Hashimi Program Manager Microsoft Corporation Contact Manager browser and mobile app

10

11 ? ASP.NET MVC WCF Web HTTP WCF REST Starter Kit WCF Web API

12 + ASP.NET MVC WCF Web HTTP WCF REST Starter Kit WCF Web API

13 ASP.NET Web API

14

15

16

17 demo Sayed Ibrahim Hashimi Program Manager Microsoft Corporation Your First Web API

18

19

20 Default Web API route routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );

21

22

23

24 Content Negotiation // Get the IContentNegotiator IContentNegotiator negotiator = Configuration.Services.GetContentNegotiator(); // Run content negotiation to select a formatter MediaTypeHeaderValue mediaType; MediaTypeFormatter formatter = negotiator.Negotiate( typeof(Contact), Request, Configuration.Formatters, out mediaType); // Create a response message with an object content using the selected formatter HttpResponseMessage response = new HttpResponseMessage() { Content = new ObjectContent (contact, formatter), RequestMessage = Request };

25 Content Negotiation HttpResponseMessage response = Request.CreateResponse (HttpStatusCode.Created, contact);

26 demo Sayed Ibrahim Hashimi Program Manager Microsoft Corporation Scaffolding an EF-based web API

27

28 Invoke Action Action filters Model Bind Select actionException filters Route to controllerFormatting RequestResponse Authorization filters

29

30 demo Sayed Ibrahim Hashimi Program Manager Microsoft Corporation OData query support

31 Http Client Handler Host Http Dispatcher Http Server Message handlers: Task SendAsync( HttpRequestMessage request, CancellationToken cancellationToken)

32 demo Sayed Ibrahim Hashimi Program Manager Microsoft Corporation URI format extensions

33

34 IApiExplorer IApiExplorer apiExplorer = config.Services.GetApiExplorer(); public interface IApiExplorer { Collection ApiDescriptions { get; } }

35 demo Sayed Ibrahim Hashimi Program Manager Microsoft Corporation Custom web API help page

36

37 demo Sayed Ibrahim Hashimi Program Manager Microsoft Corporation Flexible hosting

38

39

40

41 DEV301 ASP.NET Roadmap: One ASP.NET – Web Forms, MVC, Web API, and more DEV302 What's New in Visual Studio 2012 for Web Developers DEV303 ASP.NET Loves HTML5 DEV304 ASP.NET for Mobile and Tablet Development DEV305 Microsoft ASP.NET and the Realtime Web

42 Visual Studio Home Page :: http://www.microsoft.com/visualstudio/en-us Jason Zander’s Blog :: http://blogs.msdn.com/b/jasonz/ Facebook :: http://www.facebook.com/visualstudio Twitter :: http://twitter.com/#!/visualstudio Somasegar’s Blog :: http://blogs.msdn.com/b/somasegar/

43 Connect. Share. Discuss. http://europe.msteched.com Learning Microsoft Certification & Training Resources www.microsoft.com/learning TechNet Resources for IT Professionals http://microsoft.com/technet Resources for Developers http://microsoft.com/msdn

44 Evaluations http://europe.msteched.com/sessions Submit your evals online

45

46 Why build Web APIs?

47 http://www.asp.net/web-api/overview/testing-and-debugging/tracing-in-aspnet-web-api


Download ppt "Building HTTP Services with ASP.NET Web API Sayed Ibrahim Hashimi Program Manager Microsoft Corporation DEV309."

Similar presentations


Ads by Google