SlideShare a Scribd company logo
ASP.NET WEB API
(ADVANCED COURSE)
Trainer:Chalermpon Areepong
Microsoft MVP : ASP.NET
ASP.NET & MVCTHAI DEVELOPERS GROUP
www.fb.com/groups/mvcthaidev
ABOUT ME
 CHALERMPON AREEPONG : Nine ( )
 I’m a web developer
 Microsoft MVP ASP.NET for 7 years
 Founders in ASP.NET & MVC DevelopersThailand (MVCTHAIDEV)
AGENDA I
 WebTechnology Introduce
 ASP.NET WEB API Introduct
 ModelBinder and Custom
 Formatter and Custom
 ODATA
 Async Operation
 Performance Improvement
AGENDA II (OPTIONAL)
 Async Operation
 Performance Improvement
WEB TECHNOLOGY
INTRODUCE
HTTP
 URI : [scheme]: [port]: //[host] /[path] [? query]
 Representation : Content or Data
 MediaType : application/json, application/xml, image/png
 HTTP : HypertextTransfer Protocol
 HTTP Messages
 HTTP Request
 HTTP Response
 HTTP Method
 GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH andTRACE
HTTP METHOD
Method Objection
GET Retrieves information from a resource. return 200 (OK)
POST Requests the server to create new one of entity without duplicate object. Return code 201 (Created)
or 202 (Accepted)
PUT Requests the server to replace the state of the target resource at the specifiedURI with the enclosed
entity. If an existing resource exists for the current representation, it should return a 200(OK) ,204
(No Content) ,201 (Created).
DELETE Requests the server to remove the entity located at the specified URI. Return code 200(completed),
202 (Accepted) or 204 (No Content).
PATCH Requests the server to do a partial update of the the entity at the specified URI.The content of the
patch should have enough information that the server can use to apply the update. If the resource
exists the server and can be updated, return 200(OK), 204 (No Content),201 (Created).
HTTP METHOD
Method Objection
HEAD Identical to a GET only it returns headers and not the body.
OPTIONS Requests the server to return information about it’s capabilities. Most commonly it returns an Allow
header specifying which HTTP methods are supported, though the spec leaves it completely open
ended. For example it is entirely feasible to list which media types the server supports.OPTIONS can
also return a body supplying further information that cannot be represented in the headers.
TRACE Requests the server to return back the request it received.The server will return the entire request
message in the body with a Content-Type of "message/http".This is useful for diagnostics as clients
can see which proxies the request passed through and how the request may have been modified by
intermediaries.
CONNECT Converts the request connection to aTCPTunnel (HTTPS, websokets)
WEB COMMUNICATION
Web Server
GET
Response
GET https://www.facebook.com/groups/mvcthaidev HTTP/1.1
method: GET
accept-encoding: gzip,deflate,sdch
url: /groups/mvcthaidev
host: www.facebook.com
accept-language: en-US,en;q=0.8
user-agent: Mozilla/5.0 (Windows NT 6.1;WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94
Safari/537.36
accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
version: HTTP/1.1
scheme: https
HTTP/1.1 200 OK
cache-control: private, no-cache, no-store, must-revalidate
content-encoding: gzip
content-type: text/html; charset=utf-8
date: Sat, 25 May 2013 08:21:01 GMT
expires: Sat, 01 Jan 2000 00:00:00 GMT
p3p:CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p"
pragma: no-cache
set-cookie: wd=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly
status: 200
strict-transport-security: max-age=60
version: HTTP/1.1
x-content-type-options: nosniff
x-fb-debug: ERdqB2SxAcgCR0CJZG4+D200CnnoJPJV8k+R1bKkdi0=
x-frame-options: DENY
x-xss-protection: 0
Output :
<!DOCTYPE html>
<html lang="en" id="facebook" class="no_js"> …………………………
WEB COMMUNICATION
Web Server
POST
Response
POST https://www.facebook.com/ajax/chat/imps_logging.php HTTP/1.1
origin: https://www.facebook.com
method: POST
accept-encoding: gzip,deflate,sdch
url: /ajax/chat/imps_logging.php
host: www.facebook.com
accept-language: en-US,en;q=0.8
user-agent: Mozilla/5.0 (Windows NT 6.1;WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94
Safari/537.36
content-type: application/x-www-form-urlencoded
accept: */*
referer: https://www.facebook.com/groups/mvcthaidev
x-svn-rev: 826852
version: HTTP/1.1
content-length: 242
scheme: https
HTTP/1.1 200 OK
cache-control: private, no-cache, no-store, must-revalidate
content-encoding: gzip
content-type: application/x-javascript; charset=utf-8
date: Sat, 25 May 2013 08:21:05 GMT
expires: Sat, 01 Jan 2000 00:00:00 GMT
pragma: no-cache
status: 200
strict-transport-security: max-age=60
version: HTTP/1.1
x-content-type-options: nosniff
x-fb-debug: IPFu6HhUMaNDxBAvHb94M96B0QjjrZ7YeMdmBL4ArLQ=
x-frame-options: DENY
x-xss-protection: 0
Input: Form data
source: periodical_imps
sorted_list: 1321490013,1059545685,100000164752579,1093746402,100000165125475
list_availability: 2,2,3,2,2
__user: 712879509
__a: 1
__dyn: 7n8ahyj35CFwXAw
__req: 1
fb_dtsg: AQD81QbA
phstamp: 16581685649819865213
HTTP STATUS CODE
Range Definition Ref Link
1xx The request has been received and
processing is continuing.
http://tools.ietf.org/html/draft-ietf-httpbis-
p2-semantics-21#section-7.2
2xx The request has been accepted, received
and understood.
http://tools.ietf.org/html/draft-ietf-httpbis-
p2-semantics-21#section-7.3
3xx Further action is required to complete the
request.
http://tools.ietf.org/html/draft-ietf-httpbis-
p2-semantics-21#section-7.4
4xx The request is invalid and cannot be
completed.
http://tools.ietf.org/html/draft-ietf-httpbis-
p2-semantics-21#section-7.5
5xx he server has failed trying to complete the
request
http://tools.ietf.org/html/draft-ietf-httpbis-
p2-semantics-21#section-7.6
HTTP MEDIA FORMATS
 JSON
 XML
 Form Data
 Image
 Others https://en.wikipedia.org/wiki/Internet_media_type
JSON (JAVASCRIPT OBJECT NOTATION)
 Open standard
 Text Based format
 Lightweight than XML
 Human readable
 Derived from JavaScript object
 ContentType = application/json
 Extension *.json
JSON (JAVASCRIPT OBJECT NOTATION)
 JavaScript object
 JSON
var customer = {
fullname : “PeeMark PraKhaNhong”,
age : 500 ,
contacts : [ { mobileno: “025329000”, email : “mark@gmail.com” } ]
}
{
“fullname” : “PeeMark PraKhaNhong”,
“age” : 500 ,
“contacts” : [ { “mobileno”: “025329000”, “email” : “mark@gmail.com” } ]
}
XML (EXTENSIBLE MARKUP LANGUAGE)
 Unicode Support
 Human and Machine Readable
 Markup language like HTML <name>…</name>
 ContentType = text/xml, application/xml
 text/xml if not specified encode will use ASCII is default
 application/xml used encode in document
<Person>
<FullName>PeeMark PraKhaNhong</FullName>
<Age>500</Age>
<Contacts>
<Contact MobileNo=“025329000” Email= “mark@gmail.com” ></Contact>
</Contacts>
</Person>
FORM DATA
 Content-Type : application/x-www-form-urlencoded
 Send by Form Submit
 Format as Url Encode
Encoded :
FullName=PeeMark%20PraKhaNhong&Age=500&MobileNo=025329000&Email=mark%40gmail.com
Decoded:
FullName=PeeMark PraKhaNhong&Age=500&MobileNo=025329000&Email=mark@gmail.com
ASP.NET WEB API
INTRODUCE
WHAT’S ASP.NET WEB API
 HTTP Service
 Service based on HTTP Protocol
 GET, POST, PUT, DELETE
 No Proxy Class for client
 Support Data Format : Form Data, JSON, XML and Custom
 Support all clients are based on HTTP
 Combine ASP.NET
WHY ASP.NET WEB API?
 If we need aWeb Service and don’t need SOAP, then ASP.NetWeb API is very useful.
 Web API - Used to build simple, non-SOAP-based HTTP Services on top of existingWCF
message pipeline.
 Web API - No need for configurable likeWCF REST services
 Web API - No need for Data contracts
 Web API - Could create fully blown REST Services
 Simple service creation withWeb API.
 Web API is focused at one thing, being easy to define and expose and consume, while also
facilitating doing things in a RESTful way.
 Web API is light weight architecture.
CLIENTS
WEB SERVICETECHNOLOGY COMPARISON
Abilities ASP.NETWEB API WCF
Transport Channel HTTP(s) TCP, UDP, MSMQ, NamedPipes, HTTP(s),
Custom
Protocol HTTP WS-*
Types CLRTypes DataContract
Message format Text (xml, json) SOAP+XML
Service Interface HttpMethod, UrlPattern Service Contract
State management Stateless Stateless with per call
Cache Built-n to HTTP Prefer application
control
Handled by application
Error Handling Exceptions, HTTP Status codes
filters
Faults, Behaviors
Hosting IIS, Self Host IIS, Self Host
Client IApiExplorer
Shared Libraries
ProxyClass
Shared Libraries
WCF => ASP.NET WEB API
WCFWebAPI ASP.NET WebAPI
Service => Web API controller
Operation => Action
Service contract => n/a
Endpoint => n/a
URITemplate => ASP.NET Routing
Message handlers => Same
Formatters => Same
Operation handlers => Filters, model binders
LAB1
BASIC ASP.NET WEB API
ASP.NETWEBAPI
LAB1
BASICS
HTTP METHOD
HTTP MESSAGE
ROUTE
HTTP METHODS
 Test the API from JavaScript client
HTTP MESSAGE
 Request :
 HttpRequestMessage : represent for http request message information
 Response
 HttpResponseMessage : return data and managed http header information
 Object/Value : return data and when error will throw the exception.
 HttpResponseException : Http response message with 404(default)
HTTP MESSAGE
 Open fiddler and click ComposerTab
 1. GET http://localhost:7415/api/HttpMessages and Execute
 2. route to GetAll() action
 3.Test other method Get/Id, Post, Put, Delete
ROUTE
 Like MVC App
 Default route is api/{controller}/{id}
 Add action to route like a MVC App api/{controller}/{action}/{id}
 Force Action name with [ActionName(“name”)] to support {action}
LAB2
PIPELINE PROCESS
Message handler
PIPELINE PROCESS
 Message Handler is pre-post
processing for Http Request and Response
 Changing the request HTTP method
 Adding a response header
 Logging,Tracing
PIPELINE PROCESSTEST
LAB3
FORMATTER AND MODEL BINDING
ASP.NETWEBAPI
FORMATTER AND MODEL BINDING
 URI => ModelBinder, ValueBinder
 Entity-Body => Formatter
 URI, HEADER, Entity-body => custom format
TEST MODELBINDER
TEST MODELVALIDATE
LAB4
ODATA
ASP.NETWEBAPI
ODATA OPTION QUERY
Option Description
$filter Filters the results, based on a Boolean condition.
$inlinecount
Tells the server to include the total count of matching entities in the response. (Useful
for server-side paging.)
$orderby Sorts the results.
$skip Skips the first n results.
$top Returns only the first n the results.
ODATA QUERYTEST
 http://localhost:24556/api/meetings
 http://localhost:24556/api/meetings?$filter=Leader%20eq%20%27Mark%20Nich
ols%27  (Leader eq ‘Mark Nichols’)
 http://localhost:24556/api/meetings?$top=2
 http://localhost:24556/api/meetings?$filter=MeetingDate%20eq%20datetime%2
72013-01-17%27 MeetingDate eq datetime’2013-01-17′
ODATA QUERY RESULT
LAB6
ASYNC OPERATION
ASP.NETWEBAPI
ASYNC INWEB API
 async = Asynchronous in easy way
 async requires await
 async support in .NET 4.5 only
 .NET 4.5 provides a lot of new asynchronous methods
ASYNC RESULT
LAB7
SECURITY
TokenValidation
AUTHENTICATION SECURITY
 SSL
 All of IIS authentications
 OAuth2.0
 OpenID
 Certificate’s Client Request
 FormAuthentication
BASIC AUTHENTICATION SECURITY
 Easy solution for internet application
 SSL + BasicAuthentication + ASP.NET MembershipProvider
 Pros
 Easy
 Cons
 Username/Password encode to based 64
BASIC AUTHENTICATION SECURITY
TOKENVALIDATION
 TokenValidation = AntiForgery
DEMOTOKENVALIDATION
LAB7
PERFORMANCE IMPOVEMENT
MessageCompression
HiPerf JavaScript Serializer
MESSAGE COMPRESSION
 You can enable this feature in IIS7 or later
HI-PERFORMANCE JAVASCRIPT SERIALIZER
 ServiceStack.Text is best of faster javascriptserializer
 Create our new Custom Json Formatter and replace old
HI-PERFORMANCE JAVASCRIPT SERIALIZER
CONCLUSION
 New way for WEB Service based on HTTP
 Best the way for HTTP Service
 Support all of the HTTP Clients
 Extensibility, we able to customize all of the modules
 Closely with ASP.NET MVC
 It’s OPENSOURCE http://aspnetwebstack.codeplex.com/
 Official site http://www.asp.net/web-api
THANKYOU
REAL WORLD IMPLEMENTATION
BY
CASE STUDY
ASP.NETWEB API Advanced course II
soon…

More Related Content

What's hot

TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
Levon Apreyan
 
Cypress - Best Practices
Cypress - Best PracticesCypress - Best Practices
Cypress - Best Practices
Brian Mann
 
Test in Rest. API testing with the help of Rest Assured.
Test in Rest. API testing with the help of  Rest Assured.Test in Rest. API testing with the help of  Rest Assured.
Test in Rest. API testing with the help of Rest Assured.
Artem Korchevyi
 
testng
testngtestng
Selenium
SeleniumSelenium
Selenium
Kalyan ch
 
Apache JMeter - A brief introduction
Apache JMeter - A brief introductionApache JMeter - A brief introduction
Apache JMeter - A brief introduction
silenceIT Inc.
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
Zeba Tahseen
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
David Ličen
 
Selenium
SeleniumSelenium
LambdaTest
LambdaTestLambdaTest
LambdaTest
John Nestor
 
Selenium WebDriver with C#
Selenium WebDriver with C#Selenium WebDriver with C#
Selenium WebDriver with C#
srivinayak
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
Return on Intelligence
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
Shahed Chowdhuri
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
Er. Kamal Bhusal
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
Naresh Chintalcheru
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
Aneesh Rangarajan
 
Web Application firewall-Mod security
Web Application firewall-Mod securityWeb Application firewall-Mod security
Web Application firewall-Mod security
Romansh Yadav
 
Introduction to java 8 stream api
Introduction to java 8 stream apiIntroduction to java 8 stream api
Introduction to java 8 stream api
Vladislav sidlyarevich
 

What's hot (20)

TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
 
Cypress - Best Practices
Cypress - Best PracticesCypress - Best Practices
Cypress - Best Practices
 
Test in Rest. API testing with the help of Rest Assured.
Test in Rest. API testing with the help of  Rest Assured.Test in Rest. API testing with the help of  Rest Assured.
Test in Rest. API testing with the help of Rest Assured.
 
testng
testngtestng
testng
 
Selenium
SeleniumSelenium
Selenium
 
Apache JMeter - A brief introduction
Apache JMeter - A brief introductionApache JMeter - A brief introduction
Apache JMeter - A brief introduction
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
 
Selenium Concepts
Selenium ConceptsSelenium Concepts
Selenium Concepts
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
 
Selenium
SeleniumSelenium
Selenium
 
LambdaTest
LambdaTestLambdaTest
LambdaTest
 
Selenium WebDriver with C#
Selenium WebDriver with C#Selenium WebDriver with C#
Selenium WebDriver with C#
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Web Application firewall-Mod security
Web Application firewall-Mod securityWeb Application firewall-Mod security
Web Application firewall-Mod security
 
Introduction to java 8 stream api
Introduction to java 8 stream apiIntroduction to java 8 stream api
Introduction to java 8 stream api
 

Similar to ASP.NET WEB API Training

Ajp notes-chapter-06
Ajp notes-chapter-06Ajp notes-chapter-06
Ajp notes-chapter-06
Ankit Dubey
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
WebStackAcademy
 
Web api
Web apiWeb api
Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01
raviIITRoorkee
 
Web api
Web apiWeb api
Web api
udaiappa
 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1vikram singh
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
Nicola Pedot
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technologyvikram singh
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using Php
Sudheer Satyanarayana
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
Tiago Knoch
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web ArchitectureChamnap Chhorn
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
Jean Michel
 
Usability AJAX and other ASP.NET Features
Usability AJAX and other ASP.NET FeaturesUsability AJAX and other ASP.NET Features
Usability AJAX and other ASP.NET Features
Peter Gfader
 
Building+restful+webservice
Building+restful+webserviceBuilding+restful+webservice
Building+restful+webservicelonegunman
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009Cathie101
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009Cathie101
 
KMUTNB - Internet Programming 2/7
KMUTNB - Internet Programming 2/7KMUTNB - Internet Programming 2/7
KMUTNB - Internet Programming 2/7
phuphax
 

Similar to ASP.NET WEB API Training (20)

11 asp.net web api
11 asp.net web api11 asp.net web api
11 asp.net web api
 
Ajp notes-chapter-06
Ajp notes-chapter-06Ajp notes-chapter-06
Ajp notes-chapter-06
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 4...
 
Web api
Web apiWeb api
Web api
 
Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01Anintroductiontojavawebtechnology 090324184240-phpapp01
Anintroductiontojavawebtechnology 090324184240-phpapp01
 
Web api
Web apiWeb api
Web api
 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using Php
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
 
Restful web services
Restful web servicesRestful web services
Restful web services
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
Usability AJAX and other ASP.NET Features
Usability AJAX and other ASP.NET FeaturesUsability AJAX and other ASP.NET Features
Usability AJAX and other ASP.NET Features
 
Building+restful+webservice
Building+restful+webserviceBuilding+restful+webservice
Building+restful+webservice
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009
 
KMUTNB - Internet Programming 2/7
KMUTNB - Internet Programming 2/7KMUTNB - Internet Programming 2/7
KMUTNB - Internet Programming 2/7
 

More from Chalermpon Areepong

DevRock #02 akka.net intro part
DevRock #02 akka.net intro partDevRock #02 akka.net intro part
DevRock #02 akka.net intro part
Chalermpon Areepong
 
Web API authentication and authorization
Web API authentication and authorization Web API authentication and authorization
Web API authentication and authorization
Chalermpon Areepong
 
Build your website with angularjs and web apis
Build your website with angularjs and web apisBuild your website with angularjs and web apis
Build your website with angularjs and web apis
Chalermpon Areepong
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
Chalermpon Areepong
 
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
Chalermpon Areepong
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Chalermpon Areepong
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpChalermpon Areepong
 
Build your web app with asp.net mvc 2 from scratch
Build your web app with asp.net mvc 2 from scratchBuild your web app with asp.net mvc 2 from scratch
Build your web app with asp.net mvc 2 from scratchChalermpon Areepong
 

More from Chalermpon Areepong (10)

DevRock #02 akka.net intro part
DevRock #02 akka.net intro partDevRock #02 akka.net intro part
DevRock #02 akka.net intro part
 
Web API authentication and authorization
Web API authentication and authorization Web API authentication and authorization
Web API authentication and authorization
 
Build your website with angularjs and web apis
Build your website with angularjs and web apisBuild your website with angularjs and web apis
Build your website with angularjs and web apis
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
 
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
 
Build your web app with asp.net mvc 2 from scratch
Build your web app with asp.net mvc 2 from scratchBuild your web app with asp.net mvc 2 from scratch
Build your web app with asp.net mvc 2 from scratch
 
Gf vtzz-05--j queryshowcase
Gf vtzz-05--j queryshowcaseGf vtzz-05--j queryshowcase
Gf vtzz-05--j queryshowcase
 
J query
J queryJ query
J query
 

Recently uploaded

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 

Recently uploaded (20)

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 

ASP.NET WEB API Training

  • 1. ASP.NET WEB API (ADVANCED COURSE) Trainer:Chalermpon Areepong Microsoft MVP : ASP.NET ASP.NET & MVCTHAI DEVELOPERS GROUP www.fb.com/groups/mvcthaidev
  • 2. ABOUT ME  CHALERMPON AREEPONG : Nine ( )  I’m a web developer  Microsoft MVP ASP.NET for 7 years  Founders in ASP.NET & MVC DevelopersThailand (MVCTHAIDEV)
  • 3. AGENDA I  WebTechnology Introduce  ASP.NET WEB API Introduct  ModelBinder and Custom  Formatter and Custom  ODATA  Async Operation  Performance Improvement
  • 4. AGENDA II (OPTIONAL)  Async Operation  Performance Improvement
  • 6. HTTP  URI : [scheme]: [port]: //[host] /[path] [? query]  Representation : Content or Data  MediaType : application/json, application/xml, image/png  HTTP : HypertextTransfer Protocol  HTTP Messages  HTTP Request  HTTP Response  HTTP Method  GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH andTRACE
  • 7. HTTP METHOD Method Objection GET Retrieves information from a resource. return 200 (OK) POST Requests the server to create new one of entity without duplicate object. Return code 201 (Created) or 202 (Accepted) PUT Requests the server to replace the state of the target resource at the specifiedURI with the enclosed entity. If an existing resource exists for the current representation, it should return a 200(OK) ,204 (No Content) ,201 (Created). DELETE Requests the server to remove the entity located at the specified URI. Return code 200(completed), 202 (Accepted) or 204 (No Content). PATCH Requests the server to do a partial update of the the entity at the specified URI.The content of the patch should have enough information that the server can use to apply the update. If the resource exists the server and can be updated, return 200(OK), 204 (No Content),201 (Created).
  • 8. HTTP METHOD Method Objection HEAD Identical to a GET only it returns headers and not the body. OPTIONS Requests the server to return information about it’s capabilities. Most commonly it returns an Allow header specifying which HTTP methods are supported, though the spec leaves it completely open ended. For example it is entirely feasible to list which media types the server supports.OPTIONS can also return a body supplying further information that cannot be represented in the headers. TRACE Requests the server to return back the request it received.The server will return the entire request message in the body with a Content-Type of "message/http".This is useful for diagnostics as clients can see which proxies the request passed through and how the request may have been modified by intermediaries. CONNECT Converts the request connection to aTCPTunnel (HTTPS, websokets)
  • 9. WEB COMMUNICATION Web Server GET Response GET https://www.facebook.com/groups/mvcthaidev HTTP/1.1 method: GET accept-encoding: gzip,deflate,sdch url: /groups/mvcthaidev host: www.facebook.com accept-language: en-US,en;q=0.8 user-agent: Mozilla/5.0 (Windows NT 6.1;WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 version: HTTP/1.1 scheme: https HTTP/1.1 200 OK cache-control: private, no-cache, no-store, must-revalidate content-encoding: gzip content-type: text/html; charset=utf-8 date: Sat, 25 May 2013 08:21:01 GMT expires: Sat, 01 Jan 2000 00:00:00 GMT p3p:CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p" pragma: no-cache set-cookie: wd=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.facebook.com; httponly status: 200 strict-transport-security: max-age=60 version: HTTP/1.1 x-content-type-options: nosniff x-fb-debug: ERdqB2SxAcgCR0CJZG4+D200CnnoJPJV8k+R1bKkdi0= x-frame-options: DENY x-xss-protection: 0 Output : <!DOCTYPE html> <html lang="en" id="facebook" class="no_js"> …………………………
  • 10. WEB COMMUNICATION Web Server POST Response POST https://www.facebook.com/ajax/chat/imps_logging.php HTTP/1.1 origin: https://www.facebook.com method: POST accept-encoding: gzip,deflate,sdch url: /ajax/chat/imps_logging.php host: www.facebook.com accept-language: en-US,en;q=0.8 user-agent: Mozilla/5.0 (Windows NT 6.1;WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36 content-type: application/x-www-form-urlencoded accept: */* referer: https://www.facebook.com/groups/mvcthaidev x-svn-rev: 826852 version: HTTP/1.1 content-length: 242 scheme: https HTTP/1.1 200 OK cache-control: private, no-cache, no-store, must-revalidate content-encoding: gzip content-type: application/x-javascript; charset=utf-8 date: Sat, 25 May 2013 08:21:05 GMT expires: Sat, 01 Jan 2000 00:00:00 GMT pragma: no-cache status: 200 strict-transport-security: max-age=60 version: HTTP/1.1 x-content-type-options: nosniff x-fb-debug: IPFu6HhUMaNDxBAvHb94M96B0QjjrZ7YeMdmBL4ArLQ= x-frame-options: DENY x-xss-protection: 0 Input: Form data source: periodical_imps sorted_list: 1321490013,1059545685,100000164752579,1093746402,100000165125475 list_availability: 2,2,3,2,2 __user: 712879509 __a: 1 __dyn: 7n8ahyj35CFwXAw __req: 1 fb_dtsg: AQD81QbA phstamp: 16581685649819865213
  • 11. HTTP STATUS CODE Range Definition Ref Link 1xx The request has been received and processing is continuing. http://tools.ietf.org/html/draft-ietf-httpbis- p2-semantics-21#section-7.2 2xx The request has been accepted, received and understood. http://tools.ietf.org/html/draft-ietf-httpbis- p2-semantics-21#section-7.3 3xx Further action is required to complete the request. http://tools.ietf.org/html/draft-ietf-httpbis- p2-semantics-21#section-7.4 4xx The request is invalid and cannot be completed. http://tools.ietf.org/html/draft-ietf-httpbis- p2-semantics-21#section-7.5 5xx he server has failed trying to complete the request http://tools.ietf.org/html/draft-ietf-httpbis- p2-semantics-21#section-7.6
  • 12. HTTP MEDIA FORMATS  JSON  XML  Form Data  Image  Others https://en.wikipedia.org/wiki/Internet_media_type
  • 13. JSON (JAVASCRIPT OBJECT NOTATION)  Open standard  Text Based format  Lightweight than XML  Human readable  Derived from JavaScript object  ContentType = application/json  Extension *.json
  • 14. JSON (JAVASCRIPT OBJECT NOTATION)  JavaScript object  JSON var customer = { fullname : “PeeMark PraKhaNhong”, age : 500 , contacts : [ { mobileno: “025329000”, email : “mark@gmail.com” } ] } { “fullname” : “PeeMark PraKhaNhong”, “age” : 500 , “contacts” : [ { “mobileno”: “025329000”, “email” : “mark@gmail.com” } ] }
  • 15. XML (EXTENSIBLE MARKUP LANGUAGE)  Unicode Support  Human and Machine Readable  Markup language like HTML <name>…</name>  ContentType = text/xml, application/xml  text/xml if not specified encode will use ASCII is default  application/xml used encode in document <Person> <FullName>PeeMark PraKhaNhong</FullName> <Age>500</Age> <Contacts> <Contact MobileNo=“025329000” Email= “mark@gmail.com” ></Contact> </Contacts> </Person>
  • 16. FORM DATA  Content-Type : application/x-www-form-urlencoded  Send by Form Submit  Format as Url Encode Encoded : FullName=PeeMark%20PraKhaNhong&Age=500&MobileNo=025329000&Email=mark%40gmail.com Decoded: FullName=PeeMark PraKhaNhong&Age=500&MobileNo=025329000&Email=mark@gmail.com
  • 18. WHAT’S ASP.NET WEB API  HTTP Service  Service based on HTTP Protocol  GET, POST, PUT, DELETE  No Proxy Class for client  Support Data Format : Form Data, JSON, XML and Custom  Support all clients are based on HTTP  Combine ASP.NET
  • 19. WHY ASP.NET WEB API?  If we need aWeb Service and don’t need SOAP, then ASP.NetWeb API is very useful.  Web API - Used to build simple, non-SOAP-based HTTP Services on top of existingWCF message pipeline.  Web API - No need for configurable likeWCF REST services  Web API - No need for Data contracts  Web API - Could create fully blown REST Services  Simple service creation withWeb API.  Web API is focused at one thing, being easy to define and expose and consume, while also facilitating doing things in a RESTful way.  Web API is light weight architecture.
  • 21. WEB SERVICETECHNOLOGY COMPARISON Abilities ASP.NETWEB API WCF Transport Channel HTTP(s) TCP, UDP, MSMQ, NamedPipes, HTTP(s), Custom Protocol HTTP WS-* Types CLRTypes DataContract Message format Text (xml, json) SOAP+XML Service Interface HttpMethod, UrlPattern Service Contract State management Stateless Stateless with per call Cache Built-n to HTTP Prefer application control Handled by application Error Handling Exceptions, HTTP Status codes filters Faults, Behaviors Hosting IIS, Self Host IIS, Self Host Client IApiExplorer Shared Libraries ProxyClass Shared Libraries
  • 22. WCF => ASP.NET WEB API WCFWebAPI ASP.NET WebAPI Service => Web API controller Operation => Action Service contract => n/a Endpoint => n/a URITemplate => ASP.NET Routing Message handlers => Same Formatters => Same Operation handlers => Filters, model binders
  • 23. LAB1 BASIC ASP.NET WEB API ASP.NETWEBAPI
  • 25. HTTP METHODS  Test the API from JavaScript client
  • 26. HTTP MESSAGE  Request :  HttpRequestMessage : represent for http request message information  Response  HttpResponseMessage : return data and managed http header information  Object/Value : return data and when error will throw the exception.  HttpResponseException : Http response message with 404(default)
  • 27. HTTP MESSAGE  Open fiddler and click ComposerTab  1. GET http://localhost:7415/api/HttpMessages and Execute  2. route to GetAll() action  3.Test other method Get/Id, Post, Put, Delete
  • 28. ROUTE  Like MVC App  Default route is api/{controller}/{id}  Add action to route like a MVC App api/{controller}/{action}/{id}  Force Action name with [ActionName(“name”)] to support {action}
  • 30. PIPELINE PROCESS  Message Handler is pre-post processing for Http Request and Response  Changing the request HTTP method  Adding a response header  Logging,Tracing
  • 32. LAB3 FORMATTER AND MODEL BINDING ASP.NETWEBAPI
  • 33. FORMATTER AND MODEL BINDING  URI => ModelBinder, ValueBinder  Entity-Body => Formatter  URI, HEADER, Entity-body => custom format
  • 34.
  • 38. ODATA OPTION QUERY Option Description $filter Filters the results, based on a Boolean condition. $inlinecount Tells the server to include the total count of matching entities in the response. (Useful for server-side paging.) $orderby Sorts the results. $skip Skips the first n results. $top Returns only the first n the results.
  • 39. ODATA QUERYTEST  http://localhost:24556/api/meetings  http://localhost:24556/api/meetings?$filter=Leader%20eq%20%27Mark%20Nich ols%27  (Leader eq ‘Mark Nichols’)  http://localhost:24556/api/meetings?$top=2  http://localhost:24556/api/meetings?$filter=MeetingDate%20eq%20datetime%2 72013-01-17%27 MeetingDate eq datetime’2013-01-17′
  • 42. ASYNC INWEB API  async = Asynchronous in easy way  async requires await  async support in .NET 4.5 only  .NET 4.5 provides a lot of new asynchronous methods
  • 45. AUTHENTICATION SECURITY  SSL  All of IIS authentications  OAuth2.0  OpenID  Certificate’s Client Request  FormAuthentication
  • 46. BASIC AUTHENTICATION SECURITY  Easy solution for internet application  SSL + BasicAuthentication + ASP.NET MembershipProvider  Pros  Easy  Cons  Username/Password encode to based 64
  • 51. MESSAGE COMPRESSION  You can enable this feature in IIS7 or later
  • 52. HI-PERFORMANCE JAVASCRIPT SERIALIZER  ServiceStack.Text is best of faster javascriptserializer  Create our new Custom Json Formatter and replace old
  • 54. CONCLUSION  New way for WEB Service based on HTTP  Best the way for HTTP Service  Support all of the HTTP Clients  Extensibility, we able to customize all of the modules  Closely with ASP.NET MVC  It’s OPENSOURCE http://aspnetwebstack.codeplex.com/  Official site http://www.asp.net/web-api
  • 56. REAL WORLD IMPLEMENTATION BY CASE STUDY ASP.NETWEB API Advanced course II soon…