This document discusses improving perceived page performance in ASP.NET web applications using Web API and AJAX. It defines Web API as a client-server gateway using REST that returns JSON data and can be easily paired with client-side frameworks. AJAX is described as a way to send data between the browser and server asynchronously without disrupting the user experience. The document recommends using Web API and AJAX to eliminate full page postbacks, improve performance and user experience, and maintain clean separation of concerns in the code. It provides steps and examples for getting started with Web API in an ASP.NET application and making client-side calls.
2. About Me
• Chris Bohatka
• .NET Web Developer
• Clean Code
• UX
• @cjb5790
• http://chris.bohatka.com
3. • Founded in 1999 in Mentor, OH
• Global leader and pioneer in enabling authenticated
payments, secure transactions and alternative payment
brands
TokenizationMobile Solution Design
Consumer
Authentication
Alternative
Payments
13. What is Web API?
• Client-Server gateway via REST
• Framework
• Built on ASP.NET MVC
• Open Source
• https://github.com/aspnet/Mvc
• Available via NuGet
14. What is REST?
• Representational State Transfer
• Stateless
• Architecture
• Light Weight
• Pure HTTP
• Cacheable
• Utilizes JSON
25. Web Api Routing
• Built on top of MVC
• Uses same routing engine
• Decorate with Route attribute
• Use attributes to drive API method
• HttpGet
• HttpPost
26. Web API Advantages
Why should I use it?
• Take existing logic,
expose to client
• Supports all HTTP verbs
• Work in familiar
environment
• Eliminates Postback
• JSON Object
Serialization
• Utilize .NET Security
When to use it…
• Filtering
• Complex forms
• Complex data loads
• Pair with client side
templates
33. What is AJAX?
• Asynchronous Javascript And XML
• XML has been replaced with JSON
• A way to send data back and forth between the browser
and the server without disrupting the user experience
End up using query string parameters: if PostBack and this...
Give me 3 good reasons...
Code Maintainability: Event Driven & Stateful
Web Forms compatible
What is REST?
SOAP, REST
Longest time I was unsure of what REST really was, “oh, okay, it’s an API?”
Cacheable: GET requests
http://developer.marvel.com/docs
Less data access: no need manage state, lookup references
Less churn
Most users aren’t aware of performance optimizations
Load time = display loading gif
- dependent on server latency
Actual vs Perceived depends on server configuration
Checkout example
Event Driven, Stateful
Multiple steps, multiple pages, takes 5 min
RESTful
Multiple steps, one page, takes 2 min
Another great example, employment application
Or decision tree...interactive documentation
I told you I like Clean Code...
Snuck this one in
MVC Non-Action
N-Tier
REST API = URL driven
Web Api makes it easy with attribute routing
Work in familiar environment = .NET, Visual Studio
I used to think building REST API’s was only available in other javascript-y languages
Security:
Cross Site Forgery Token
Security through POST
Intentionally Left Blank
Module Pattern
Cleaner
Trojan War Hero
Amsterdam Football Club (most successful)
Deadpool Villain, like The Hulk