SlideShare a Scribd company logo
ASP.NET Web API



Udaiappa Ramachandran
NHDN-Nashua .NET/Cloud Computing UG Lead
Email: udaiappa@gmail.com
Blog: http://cloudycode.wordpress.com
Agenda
 Introduction to Web API
 Web API Routing
 Web API Pipeline
 Dependency Injections and Resolvers
 Model Binding and Media Formats
 Self Hosting
 Deploying Web API into cloud
 References
Introduction to Web API
 Next iteration of WCF REST
 Framework for developing REST Services
 Released part of ASP.NET MVC
 Uses HTTP protocol
 Accessible from wide variety of clients
 Http Methods: GET, POST, PUT, DELETE
 URLs and Methods
Demo: Web API Basics
Web API Routing
   Web API Routing very similar to MVC routing
   Action determined using the HTTP method not the URI path
   Uses “api” in the rout is to avoid collisons with ASP.NET MVC
    routing.
   Adds “Controller” to the controller part of the URL
   Default mapping thru global.asax
   Additional URL parameters are mapped as action parameters
   Explicitly specify the HTTP methods for an action by decorating
    the action method with HttpGet, HttpPut, HttpPost or
    HttpDelete attribute
   Action can be defined thru AcceptVerbs as a method attributes
   Route by Action Name
   Override action name by using ActionName attribute
   Ignore action by NoAction Attribute
Demo: Web API Routing
Filtering
   Uses OData specific keywords
               Directs that related records should be retrieved in the record or collection
    $expand
               being retrieved.
               Specifies an expression or function that must evaluate to ‘true’ for a record to
    $filter
               be returned in the collection.

    $orderby   Determines what values are used to order a collection of records.

    $select    Specifies a sub set of properties to return.

    $skip      Sets the number of records to skip before it retrieves records in a collection.


    $top       Determines the maximum number of records to return.


      Install-Package Microsoft.AspNet.WebApi.OData -Pre
Demo: Web API Filtering
Web API Pipeline
   Both Request and Response Model have pipeline
   Web API has client and server side pipelines
   Both Share the common object HttpMessageHandler
   HttpRequestMessage
     Represents all info about http request such as URL, HTTP Methods and
        Headers
   HttpResponseMessage
     Represents all the info about the Http Response such as StatusCode,
        Success Flag, Original Http Request
   HttpMessageHandler
       Common for both Request and Response
       Most common processing code can be placed here
       Ideal for authentication
       Two Scopes: Global and Per-Route
   Custom Handlers
     Inherit DelegatingHandler
     Custom code to perform any kind of per request functionality
Pipeline Elements
Pipeline Elements
Demo: Web API Pipeline
Demo: Custom Handlers
Dependency Resolution
 Service Oriented Architecture for Decoupling the
  object
 IoC: The concept of allowing something outside of
  system to control it.
 Often done thru DI frameworks
       Unity
       Ninject
       Castle Windsor
       Structure Map
       Spring.net
       Autofac
   Web API provides a hook for us to wire up the
    complex dependency
Demo: Simple Resolver
Demo: Resolve using DI Framework
Data Model and MIME types
   Returning JSON
     Default return format
     Good for mobile apps
     does not require any special code
   Returning XML
     No code change
     Set the request content type as application/xml
   Mime Types:
       return virtually anything that can be sent over the web
       Inherit from BufferedMediaTypeFormatter
       Override key methods
       attach media formatter to configuration
Demo: Data Model
Demo: MIME Types
Hosting
   IIS
    
    
    


   Self Hosting
    
    
    
    
Web api
Demo: Self Hosting
Resource
 http://cloudycode.wordpress.com
 http://www.asp.net/web-api/overview
 http://code.msdn.microsoft.com/ASPNET-Web-API-Self-
  Host-30abca12
 http://msdn.microsoft.com/en-us/library/gg309461.aspx
 http://blogs.msdn.com/b/webdev/archive/2012/08/26/asp-
  net-web-api-and-httpclient-samples.aspx
Q&A

More Related Content

PPT
Web controls
KEY
CakePHP REST Plugin
PPTX
ASP.NET Web API
PPTX
CakeFest 2013 - A-Z REST APIs
PPTX
Integration with dropbox using mule esb
PPTX
ASP.NET WEB API Training
PPTX
The ASP.NET Web API for Beginners
PPT
Asp.net server controls
Web controls
CakePHP REST Plugin
ASP.NET Web API
CakeFest 2013 - A-Z REST APIs
Integration with dropbox using mule esb
ASP.NET WEB API Training
The ASP.NET Web API for Beginners
Asp.net server controls

What's hot (20)

PPT
ASP.NET 03 - Working With Web Server Controls
PPTX
PPTX
ASP.NET Mvc 4 web api
ODP
Spray - Build RESTfull services in scala
PPT
Backbone js
PPTX
Integration of mule esb with microsoft azure
PPT
RichControl in Asp.net
PDF
Request-Response Cycle of Ruby on Rails App
PDF
Building RESTful applications using Spring MVC
PDF
using Mithril.js + postgREST to build and consume API's
PPT
Anypoint connectorfor ibm as 400
PPT
Server Controls of ASP.Net
PPT
Silverlight 2
PPTX
PostgREST Design Philosophy
PPT
Data controls ppt
PPTX
PPT
Mobile Interface to CMS Based On HTML5 and Drupal: A Case Study
PPTX
Slim Framework
PPTX
Presentation on asp.net controls
ASP.NET 03 - Working With Web Server Controls
ASP.NET Mvc 4 web api
Spray - Build RESTfull services in scala
Backbone js
Integration of mule esb with microsoft azure
RichControl in Asp.net
Request-Response Cycle of Ruby on Rails App
Building RESTful applications using Spring MVC
using Mithril.js + postgREST to build and consume API's
Anypoint connectorfor ibm as 400
Server Controls of ASP.Net
Silverlight 2
PostgREST Design Philosophy
Data controls ppt
Mobile Interface to CMS Based On HTML5 and Drupal: A Case Study
Slim Framework
Presentation on asp.net controls
Ad

Viewers also liked (20)

PPTX
ZFConf 2010: Proposal Lifecycle
PPTX
DealinDougCommunity.com - ArapahoeOnline.com; 2009 AAA Aggressive Driving Res...
RTF
PPT
Малобюджетный маркетинг
PDF
Prk acta intercentos_13062012
PDF
TDR - Predstavljanje poslovanja za 2009. godinu
PPT
Proyecto Cactus 1°3vesp
PPT
LD_March2010_forweb
PPTX
Yaşamboyu Öğrenme
PPTX
Homophones Lesson
PPT
Hyves Cbw Mitex Harry Van Wouter
PPT
Web 2 0
PDF
Komogortsev Qualitative And Quantitative Scoring And Evaluation Of The Eye Mo...
DOC
מכרות הגפרית בבארי
PDF
Goldberg Scanpath Clustering And Aggregation
PPT
TEMA 1B GRAMMAR ADJECTIVES
PDF
Doing Business With Aboriginal People
DOC
Movie it process
PDF
Acta santiago barbanza
PDF
MobileConf 2013 - Aerogear Android
ZFConf 2010: Proposal Lifecycle
DealinDougCommunity.com - ArapahoeOnline.com; 2009 AAA Aggressive Driving Res...
Малобюджетный маркетинг
Prk acta intercentos_13062012
TDR - Predstavljanje poslovanja za 2009. godinu
Proyecto Cactus 1°3vesp
LD_March2010_forweb
Yaşamboyu Öğrenme
Homophones Lesson
Hyves Cbw Mitex Harry Van Wouter
Web 2 0
Komogortsev Qualitative And Quantitative Scoring And Evaluation Of The Eye Mo...
מכרות הגפרית בבארי
Goldberg Scanpath Clustering And Aggregation
TEMA 1B GRAMMAR ADJECTIVES
Doing Business With Aboriginal People
Movie it process
Acta santiago barbanza
MobileConf 2013 - Aerogear Android
Ad

Similar to Web api (20)

PPTX
Web API or WCF - An Architectural Comparison
PPTX
Implementation web api
PPTX
C# web api
PPTX
06 web api
PPTX
Asp.net web api
PPTX
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
PPTX
Mastering-ASPNET-Web-API-and-RESTful-Patterns.pptx
PPTX
Rest WebAPI with OData
PPTX
Will be an introduction to
PPTX
Building-Robust-APIs-ASPNET-Web-API-and-RESTful-Patterns.pptx
PDF
MS TechDays 2011 - WCF Web APis There's a URI for That
PDF
ASP.NET Web API Interview Questions By Scholarhat
PPTX
REST and ASP.NET Web API (Tunisia)
PPTX
Real-Time Web Applications with ASP.NET WebAPI and SignalR
PPTX
Building Software Backend (Web API)
PDF
Unleash the power of HTTP with ASP.NET Web API
PDF
ASP NET Web API 2 Building a REST Service from Start to Finish 2nd Edition Ja...
PPTX
ASP.NET - Building Web Application..in the right way!
PPTX
ASP.NET - Building Web Application..in the right way!
PPTX
Enjoying the Move from WCF to the Web API
Web API or WCF - An Architectural Comparison
Implementation web api
C# web api
06 web api
Asp.net web api
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
Mastering-ASPNET-Web-API-and-RESTful-Patterns.pptx
Rest WebAPI with OData
Will be an introduction to
Building-Robust-APIs-ASPNET-Web-API-and-RESTful-Patterns.pptx
MS TechDays 2011 - WCF Web APis There's a URI for That
ASP.NET Web API Interview Questions By Scholarhat
REST and ASP.NET Web API (Tunisia)
Real-Time Web Applications with ASP.NET WebAPI and SignalR
Building Software Backend (Web API)
Unleash the power of HTTP with ASP.NET Web API
ASP NET Web API 2 Building a REST Service from Start to Finish 2nd Edition Ja...
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
Enjoying the Move from WCF to the Web API

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Electronic commerce courselecture one. Pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Modernizing your data center with Dell and AMD
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A Presentation on Artificial Intelligence
Electronic commerce courselecture one. Pdf
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Monthly Chronicles - July 2025
Modernizing your data center with Dell and AMD
Dropbox Q2 2025 Financial Results & Investor Presentation
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Building Integrated photovoltaic BIPV_UPV.pdf
cuic standard and advanced reporting.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

Web api

  • 1. ASP.NET Web API Udaiappa Ramachandran NHDN-Nashua .NET/Cloud Computing UG Lead Email: udaiappa@gmail.com Blog: http://cloudycode.wordpress.com
  • 2. Agenda  Introduction to Web API  Web API Routing  Web API Pipeline  Dependency Injections and Resolvers  Model Binding and Media Formats  Self Hosting  Deploying Web API into cloud  References
  • 3. Introduction to Web API  Next iteration of WCF REST  Framework for developing REST Services  Released part of ASP.NET MVC  Uses HTTP protocol  Accessible from wide variety of clients  Http Methods: GET, POST, PUT, DELETE  URLs and Methods
  • 4. Demo: Web API Basics
  • 5. Web API Routing  Web API Routing very similar to MVC routing  Action determined using the HTTP method not the URI path  Uses “api” in the rout is to avoid collisons with ASP.NET MVC routing.  Adds “Controller” to the controller part of the URL  Default mapping thru global.asax  Additional URL parameters are mapped as action parameters  Explicitly specify the HTTP methods for an action by decorating the action method with HttpGet, HttpPut, HttpPost or HttpDelete attribute  Action can be defined thru AcceptVerbs as a method attributes  Route by Action Name  Override action name by using ActionName attribute  Ignore action by NoAction Attribute
  • 6. Demo: Web API Routing
  • 7. Filtering  Uses OData specific keywords Directs that related records should be retrieved in the record or collection $expand being retrieved. Specifies an expression or function that must evaluate to ‘true’ for a record to $filter be returned in the collection. $orderby Determines what values are used to order a collection of records. $select Specifies a sub set of properties to return. $skip Sets the number of records to skip before it retrieves records in a collection. $top Determines the maximum number of records to return. Install-Package Microsoft.AspNet.WebApi.OData -Pre
  • 8. Demo: Web API Filtering
  • 9. Web API Pipeline  Both Request and Response Model have pipeline  Web API has client and server side pipelines  Both Share the common object HttpMessageHandler  HttpRequestMessage  Represents all info about http request such as URL, HTTP Methods and Headers  HttpResponseMessage  Represents all the info about the Http Response such as StatusCode, Success Flag, Original Http Request  HttpMessageHandler  Common for both Request and Response  Most common processing code can be placed here  Ideal for authentication  Two Scopes: Global and Per-Route  Custom Handlers  Inherit DelegatingHandler  Custom code to perform any kind of per request functionality
  • 12. Demo: Web API Pipeline Demo: Custom Handlers
  • 13. Dependency Resolution  Service Oriented Architecture for Decoupling the object  IoC: The concept of allowing something outside of system to control it.  Often done thru DI frameworks  Unity  Ninject  Castle Windsor  Structure Map  Spring.net  Autofac  Web API provides a hook for us to wire up the complex dependency
  • 14. Demo: Simple Resolver Demo: Resolve using DI Framework
  • 15. Data Model and MIME types  Returning JSON  Default return format  Good for mobile apps  does not require any special code  Returning XML  No code change  Set the request content type as application/xml  Mime Types:  return virtually anything that can be sent over the web  Inherit from BufferedMediaTypeFormatter  Override key methods  attach media formatter to configuration
  • 17. Hosting  IIS     Self Hosting    
  • 20. Resource  http://cloudycode.wordpress.com  http://www.asp.net/web-api/overview  http://code.msdn.microsoft.com/ASPNET-Web-API-Self- Host-30abca12  http://msdn.microsoft.com/en-us/library/gg309461.aspx  http://blogs.msdn.com/b/webdev/archive/2012/08/26/asp- net-web-api-and-httpclient-samples.aspx
  • 21. Q&A