public class uslocationrecord { public int id { get; set; } public string zipcode { get; set; }...
TRANSCRIPT
![Page 1: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/1.jpg)
![Page 2: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/2.jpg)
ASP.NET Web APIWeb Services for Web Sites and Modern & Mobile AppsBrady GasterWindows Azure Technical Evangelist
DEV-B360
![Page 3: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/3.jpg)
IntroductionsIt always helps to know who you’re dealing with, so here’s a little background on me.
@bradygaster
1 Wife (Gina)
2 Chihuahuas (Lola & Nico)
Windows Azure Technical Evangelist
bradygaster.com
2 Sons (Gabe & Lucas)
Originally from NC (hence the funny accent)
2 Guitars (Fender, Gretsch)
![Page 4: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/4.jpg)
AgendaWhat are we going to talk about today?
Web API Test Clients
Modern Apps with Windows 8
Mobile Apps with Xamarin
Example Scenario
Portable Class Libraries
Mobile Apps with Windows Phone 8
Authentication with Web APICross Origin Resource Sharing
![Page 5: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/5.jpg)
Example ScenarioHere’s a look at the database we’re going to expose using a Web API
![Page 6: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/6.jpg)
Example ScenarioEntity Framework Class View Model Classpublic class UsLocationRecord{ public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string State { get; set; } public DbGeography Location { get; set; }}
public class UsLocation{ public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string State { get; set; } public double Latitude { get; set; } public double Longitude { get; set; }}
This doesn’t serialize too well, so we need a View Model
There. That’s better.
![Page 7: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/7.jpg)
Demo
Running the Sample API
![Page 8: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/8.jpg)
Web API Test ClientNuGet Package
NuGet Package Link: http://aka.ms/Kuqhny
Any browser
Templates are .CSHTML files
Introduction and how-to:http://aka.ms/webapitestclientintro
![Page 9: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/9.jpg)
PostmanChrome Plugin
http://www.getpostman.com/
![Page 10: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/10.jpg)
Demo
Setting up and using the Web API Test Client
![Page 11: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/11.jpg)
.NET is supported by many platformsMany tricks have been employed to write reusable components that work on all of them
Code Files for “reusable” classes
Models.SilverlightModels.Phone Models.WindowsModels
UX.SilverlightUX.Phone UX.WindowsUX.Web
ApiClient.SilverlightApiClient.Phone ApiClient.WindowsApiClient.Web
“reused code” isn’t the same as“reusable code”
![Page 12: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/12.jpg)
Portable Class LibrariesCommon code that can be shared across all the .NET environments
Code Files for reusable classes
UX.SilverlightUX.Phone UX.WindowsUX.Web
Common PCL
![Page 13: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/13.jpg)
Demo
Writing a Portable Class Library to Provide a client API
![Page 14: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/14.jpg)
Client Platform
Modern and Mobile ClientsWindows 8 Store Apps and Windows Phone 8 Apps can use the PCL
Windows 8Store App
Windows Phone 8 App
PCL HTTP
Server Platform
Web API Controller
![Page 15: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/15.jpg)
Demo
Using Web API in Modern Apps with Windows 8
![Page 16: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/16.jpg)
Demo
Using Web API in Mobile Apps with Windows Phone 8
![Page 17: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/17.jpg)
XamarinC# everywhere, even on iOS and Android
![Page 18: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/18.jpg)
Demo
Communicating with a Web API using a C# Android Client
![Page 19: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/19.jpg)
Sharing Data Across APIs Should be EasyMy web site has an API, your web site has an API, let’s make a mash-up!
foo.com bar.comHTML
AJAX
HTTP Request
AJAX(from pagehosted onfoo.com)
?JSON
![Page 20: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/20.jpg)
CORS
Cross Origin Resource SharingOnce CORS is enabled, cross-domain communication via AJAX/HTTP/JavaScript is possible
foo.com bar.comHTML
AJAX
JSON
AJAX
JSON
![Page 21: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/21.jpg)
Demo
Enabling Cross Origin Resource Sharing
![Page 22: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/22.jpg)
Web API & AuthenticationThe framework & tooling release will make API simple & allow for federationWeb API app configured to use OAuth Bearer TokensClient app asks Web API what OAuth providers it supportsUser selects provider and is redirected to loginUpon login, user redirected back to API site with credential stringCredential string is parsed into a claim, then an identityUserInfo is passed back to client where it is persistedUserInfo’s access token is attached to each API request as a Bearer Token HeaderAPI performs authorization using the Bearer Token Header
![Page 23: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/23.jpg)
Demo
Walking through a Multi-client Authentication Process
![Page 24: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/24.jpg)
Related contentBreakout Sessions (session codes and titles)Hands-on Labs (session codes and titles)Product Demo Stations (demo station title and location)Related Certification ExamFind Me Later At...
![Page 25: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/25.jpg)
Track resourcesGeneric Client REST Wrapperhttps://gist.github.com/bradygaster/5682105Web API Test Client How-tohttp://aka.ms/webapitestclientintroASP.NET on CodePlexhttp://aspnetwebstack.codeplex.com/Channel Web Camps TV EpisodesKatana - http://aka.ms/C7xunhCORS - http://aka.ms/Q3uthfOData - http://aka.ms/Txrdhu, http://aka.ms/V4n6cvYao’s Web API Tour - http://aka.ms/G24zpi
![Page 26: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/26.jpg)
msdnResources for Developers
http://microsoft.com/msdn
LearningMicrosoft Certification & Training Resources
www.microsoft.com/learning
TechNet
Resources
Sessions on Demandhttp://channel9.msdn.com/Events/TechEd
Resources for IT Professionalshttp://microsoft.com/technet
![Page 27: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/27.jpg)
Complete an evaluation on CommNet and enter to win!
![Page 28: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/28.jpg)
MS tag
Scan the Tagto evaluate this session now on myTechEd Mobile
![Page 29: public class UsLocationRecord { public int Id { get; set; } public string ZipCode { get; set; } public string City { get; set; } public string](https://reader036.vdocument.in/reader036/viewer/2022062223/5a4d1ad47f8b9ab0599725c6/html5/thumbnails/29.jpg)
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.