SlideShare a Scribd company logo
Intro to Single Page
Applications Using
JavaScript and ASP.NET

Alan Hecht
What is a Single Page
Application?
• The web equivalent of a desktop application

• The application is written with HTML, CSS,
and JavaScript

• Unlike regular web sites, no page loads take
place after initialization.
Characteristics of a SPA
• Launched from a single HTML page or view

• The page is fairly interactive, like a desktop
application

• Portions of the page (sometimes very large
portions) rendered client side by JavaScript
Architectural Overview
Browser - Web App
HTML / CSS / JS
Navigation /
AJAX
UI
HTML / CSS / JS

AJAX

REST API - JSON

Business Logic
JavaScript in the Browser
• Single thread handles all events, UI and nonUI
• Synchronous events stop all further processing
until done, which locks the UI
• Asynchronous events are queued until callback
function is called. Other events handled in the
meantime
Asynchronous JavaScript
• Code is non-blocking. Callbacks aren’t invoked
until code is done executing and the thread is
waiting for events to execute.
• Good analogy is the front window at the
doctor’s office
• Good for I/O intensive applications but not
CPU intensive applications
Async JavaScript Example
AJAX
• Asynchronous JavaScript and XML (now use
JSON instead of XML)

• Browser makes an asynchronous HTTP
request, callback function is called upon
completion
REST
•Representational State Transfer

•Building your web API using HTTP instead of on
top of HTTP (like SOAP)
REST
•Four HTTP verbs used: GET, PUT, POST, and
DELETE

•Use URL path segments instead of query
parameters or payload data
REST Example
HTTP GET /users
- get a list of users
HTTP GET /users/1
- get info for user id 1
HTTP POST /users
- create a new user
HTTP DELETE /users/1 - delete user id 1
HTTP PUT /users/1
- update user id 1
JSON
• JavaScript Object Notation

• Collection of key-value pairs and lists of keyvalue pairs

• Has replaced XML as a data format because
of simplicity
JSON Example
Structuring JavaScript Code
• For non-trivial, interactive web apps, you’ll
want to use a framework which at least has the
concept of models and views along with how
they get updated
• A JavaScript framework architected with MVC,
MVVM, MVP, or MV-Whatever helps structure
the UI (will be using MVC as a ‘shorthand’
here)
What about jQuery?
• jQuery is great but alone doesn’t scale well for
more complicated apps

• For larger apps, you would likely wind up with
data scattered about the DOM in ‘data-’
attributes and view logic tied to a particular
HTML layout
Client Side JavaScript MVC Frameworks
Just pick one…
JavaScript Framework Philosophy
• Have lots of specialized frameworks that do
one thing well, mix and match as needed
(you’ll see this in Node.js)
• But most of us are just trying to solve a
business problem and don’t wish to engage in
endless research
• Nobody has won the client side JS MVC
framework battle the way jQuery won with
DOM manipulation & CSS selectors
Scott Hanselman’s JavaScript Glossary
• Great overview important and innovative client
side JavaScript frameworks:
http://www.hanselman.com/blog/TheBigGlossa
ryOfOpenSourceJavaScriptAndWebFramewor
ksWithCoolNames.aspx

• Includes open source ASP.NET server side
libraries that are innovative
JS MVC Frameworks - How to Decide
• At the end of 2013, the most popular as
measured by Stack Overflow activity are:
Backbone.js, Ember.js, Angular,js,
Knockout.js, Dojo, and Ext.js

• Best article I’ve seen which compares and
evaluates JavaScript MVC frameworks while
not making a recommendation is:
http://www.funnyant.com/choosing-javascriptmvc-framework/
TodoMVC.com
• Sample Todo application written in each and
every JavaScript Model/View/* framework

• Gives a sense of how much structure and
boilerplate code is needed to create a web app
with a given framework
TodoMVC.com
Backbone.js

•Contains the minimal set of models, collections,
views, and URL functionality needed to build a
web application

•Good for experienced JavaScript developers
Marionette.js
• Built off of backbone.js

• Reduces boilerplate code, especially in the
views

• Can be incorporated piecemeal
Backbone.js & Marionette.js
Examples
Backbone.js Routing
•Anything in a URL after the ‘#’ is for client side
navigation representing a ‘view’. Classic
example is AJAX pagination.
•With a small, trivial application, a ‘switch’
statement will likely work.
•For a more substantial application, something
more formal which handles client side URL
routes is usually needed
Ember.js
• Framework with an opinionated way of building
web applications
• Modeled after the Cocoa framework in iOS
development and Ruby on Rails to a lesser
extent
• Designed for building desktop-like web
applications
Ember.js Example
Ember.js Templates
• Client-side view templating which contains
expressions that can be replaced with values

• Templates can reside in separate files that are
loaded and compiled.
Ember.js & Discourse
• Discourse is a large, open source, forum web
application which uses Ember.js
• Looks like a good non-trivial example of how to
use Ember.js
• Server side is Ruby on Rails, but just go to the
app/assets/javascripts directory and you’ll be
all set.
Angular.js
• Toolset for building the framework for web
applications
• What HTML would look like if it were designed
for building web applications
• Designed with testing in mind (dependency
injection and plays well with testing tools)
Angular.js Example
Angular.js Directives
• Allow you to create custom HTML attributes,
elements, or classes
• The Angular compiler traverses the DOM on the
client looking for pre-built or new directives.
Angular.js Services
• Functions that carry out specific tasks. Angular
includes built-in services but custom ones can
be created

• Services added via dependency injection
Knockout.js
• Based on Model-View-ViewModel architecture
just like WPF & Silverlight
• Focuses on UI data binding
• For apps bigger than a few pages, likely need
other components like client-side routing
Knockout.js – Example
Ext.js
• Framework for building desktop-like applications
• Works better for internal applications because
it’s so heavyweight
• Steep learning curve
• First stable release back in 2007
Ext.js - Example
Dojo
• Toolkit for building desktop-like applications
• Extensive HTML widgets
• Documentation not so great
• First stable release back in 2007
What about jQuery?
• Ember.js depends on jQuery
• Angular.js can use jQuery or include its own
slimmed down version of it
• Backbone.js, Knockout.js, Ext.js work with
jQuery
Building a REST API
• Best options are ASP.NET Web API or WCF
REST
• Could use ASP.NET MVC or even an asmx
web service if on Web Forms
• The API can be (and often is) used native
mobile applications as well.
ASP.NET Web API
• Designed to build APIs, not web sites
• Unlike ASP.NET MVC, controllers return data
and not views
• Content type (i.e. JSON or XML) is negotiated,
not specified, via HTTP ‘Accept’ header
ASP.NET Web API Controllers
• Controllers derive from “ApiController” instead
of “Controller” like they do in ASP.NET MVC

• HTTP methods bound to controller methods by
start of method (“Get”, “Post”, “Put”, etc.) or with
an attribute ([HttpGet], [HttpPost], [HttpPut],
etc.)
ASP.NET Web API - Routing
• By default, the route is “api/{controller}/{id}”, and
“api” is used to avoid collisions with ASP.NET
MVC routing
ASP.NET Web API - Example
Issues
Back Button
• Back button only works if the URL changes
• Ember.js, angular.js, and backbone.js have
some built in support
• Can use HTML5 History API with knockout.js
What about SEO?
• Web crawlers at the end of 2013 don’t handle
JavaScript
• Content to the right of ‘#’ in the URL isn’t sent to
the server, Google converts #! to an
‘_escaped_fragment_’ Huh?!?!
• Experimental work with using Node.js to render
the page on the server
Ad

More Related Content

What's hot (20)

Alfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring MvcAlfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring Mvc
Daniel Gradecak
 
Fluxible
FluxibleFluxible
Fluxible
Taylor Lovett
 
ASP.NET Brief History
ASP.NET Brief HistoryASP.NET Brief History
ASP.NET Brief History
Sudhakar Sharma
 
ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6
Andy Butland
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?
Eduard Tomàs
 
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORKSpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
SpringPeople
 
Building rest services using aspnetwebapi
Building rest services using aspnetwebapiBuilding rest services using aspnetwebapi
Building rest services using aspnetwebapi
Brij Mishra
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
Omri Spector
 
MVC 1.0 als alternative Webtechnologie
MVC 1.0 als alternative WebtechnologieMVC 1.0 als alternative Webtechnologie
MVC 1.0 als alternative Webtechnologie
OPEN KNOWLEDGE GmbH
 
MVC 6 Introduction
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
Sudhakar Sharma
 
Introduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJSIntroduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6
Ido Flatow
 
Scala and Lift
Scala and LiftScala and Lift
Scala and Lift
Sander Mak (@Sander_Mak)
 
SpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring FrameworkSpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring Framework
SpringPeople
 
Introduce flux & react in practice
Introduce flux & react in practiceIntroduce flux & react in practice
Introduce flux & react in practice
Hsuan Fu Lien
 
Introduction to ASP.NET 5
Introduction to ASP.NET 5Introduction to ASP.NET 5
Introduction to ASP.NET 5
mbaric
 
Building & Testing Scalable Rails Applications
Building & Testing Scalable Rails ApplicationsBuilding & Testing Scalable Rails Applications
Building & Testing Scalable Rails Applications
evilmike
 
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Aaron Jacobson
 
Building real time app by using asp.Net Core
Building real time app by using asp.Net CoreBuilding real time app by using asp.Net Core
Building real time app by using asp.Net Core
Commit Software Sh.p.k.
 
ReactPHP + Symfony
ReactPHP + SymfonyReactPHP + Symfony
ReactPHP + Symfony
David Bergunder
 
Alfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring MvcAlfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring Mvc
Daniel Gradecak
 
ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6
Andy Butland
 
Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?
Eduard Tomàs
 
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORKSpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
SpringPeople Building Web Sites with ASP.NET MVC FRAMEWORK
SpringPeople
 
Building rest services using aspnetwebapi
Building rest services using aspnetwebapiBuilding rest services using aspnetwebapi
Building rest services using aspnetwebapi
Brij Mishra
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
Omri Spector
 
MVC 1.0 als alternative Webtechnologie
MVC 1.0 als alternative WebtechnologieMVC 1.0 als alternative Webtechnologie
MVC 1.0 als alternative Webtechnologie
OPEN KNOWLEDGE GmbH
 
Introduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJSIntroduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6
Ido Flatow
 
SpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring FrameworkSpringPeople Introduction to Spring Framework
SpringPeople Introduction to Spring Framework
SpringPeople
 
Introduce flux & react in practice
Introduce flux & react in practiceIntroduce flux & react in practice
Introduce flux & react in practice
Hsuan Fu Lien
 
Introduction to ASP.NET 5
Introduction to ASP.NET 5Introduction to ASP.NET 5
Introduction to ASP.NET 5
mbaric
 
Building & Testing Scalable Rails Applications
Building & Testing Scalable Rails ApplicationsBuilding & Testing Scalable Rails Applications
Building & Testing Scalable Rails Applications
evilmike
 
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Aaron Jacobson
 
Building real time app by using asp.Net Core
Building real time app by using asp.Net CoreBuilding real time app by using asp.Net Core
Building real time app by using asp.Net Core
Commit Software Sh.p.k.
 

Viewers also liked (16)

WebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceWebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer Conference
AllFacebook.de
 
Writing SPA in 2017
Writing SPA in 2017Writing SPA in 2017
Writing SPA in 2017
Arek Flinik
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajax
s_pradeep
 
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Edureka!
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
Bharat_Kumawat
 
Single page application
Single page applicationSingle page application
Single page application
Jeremy Lee
 
Single page application
Single page applicationSingle page application
Single page application
Ismaeel Enjreny
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
thinkphp
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
hchen1
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
John Staveley
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
Hema Prasanth
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Nir Elbaz
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
Smithss25
 
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUISPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
andrew.macleod
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Raja V
 
Ajax.ppt
Ajax.pptAjax.ppt
Ajax.ppt
MAGNA COLLEGE OF ENGINEERING
 
WebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceWebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer Conference
AllFacebook.de
 
Writing SPA in 2017
Writing SPA in 2017Writing SPA in 2017
Writing SPA in 2017
Arek Flinik
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajax
s_pradeep
 
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Webinar on Angular JS titled 'Develop Responsive Single Page Application'
Edureka!
 
Single page application
Single page applicationSingle page application
Single page application
Jeremy Lee
 
Ajax Introduction Presentation
Ajax   Introduction   PresentationAjax   Introduction   Presentation
Ajax Introduction Presentation
thinkphp
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
hchen1
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
John Staveley
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Nir Elbaz
 
Ajax ppt - 32 slides
Ajax ppt - 32 slidesAjax ppt - 32 slides
Ajax ppt - 32 slides
Smithss25
 
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUISPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
SPA 2009 - Acceptance Testing AJAX Web Applications through the GUI
andrew.macleod
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Raja V
 
Ad

Similar to Intro to SPA using JavaScript & ASP.NET (20)

mearn-stackjdksjdsfjdkofkdokodkojdj.pptx
mearn-stackjdksjdsfjdkofkdokodkojdj.pptxmearn-stackjdksjdsfjdkofkdokodkojdj.pptx
mearn-stackjdksjdsfjdkofkdokodkojdj.pptx
aravym456
 
mearn-stack-new_ccvbhbhvgvgcdszsxdxfcf.pptx
mearn-stack-new_ccvbhbhvgvgcdszsxdxfcf.pptxmearn-stack-new_ccvbhbhvgvgcdszsxdxfcf.pptx
mearn-stack-new_ccvbhbhvgvgcdszsxdxfcf.pptx
aravym456
 
Meanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore ChandraMeanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore Chandra
Kishore Chandra
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
Krishnaprasad k
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
Krishnaprasad k
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
Balajihope
 
Mean stack
Mean stackMean stack
Mean stack
RavikantGautam8
 
Javascript frameworks
Javascript frameworksJavascript frameworks
Javascript frameworks
RajkumarJangid7
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and React
Mike Melusky
 
Evolution of java script libraries
Evolution of java script librariesEvolution of java script libraries
Evolution of java script libraries
Columbia Developers Guild
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
Kasey McCurdy
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
HabileLabs
 
9 Best JavaScript Frameworks To Choose
9 Best JavaScript Frameworks To Choose9 Best JavaScript Frameworks To Choose
9 Best JavaScript Frameworks To Choose
Albiorix Technology
 
Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Review
netc2012
 
React vs Vue JS Explained | Vue JS vs React Which Is Better? | Vue JS for Beg...
React vs Vue JS Explained | Vue JS vs React Which Is Better? | Vue JS for Beg...React vs Vue JS Explained | Vue JS vs React Which Is Better? | Vue JS for Beg...
React vs Vue JS Explained | Vue JS vs React Which Is Better? | Vue JS for Beg...
Simplilearn
 
Single page application and Framework
Single page application and FrameworkSingle page application and Framework
Single page application and Framework
Chandrasekar G
 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdev
damianofusco
 
React Tech Salon
React Tech SalonReact Tech Salon
React Tech Salon
Chenguang ZHANG
 
Web Development Today
Web Development TodayWeb Development Today
Web Development Today
bretticus
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the web
Sigma Software
 
mearn-stackjdksjdsfjdkofkdokodkojdj.pptx
mearn-stackjdksjdsfjdkofkdokodkojdj.pptxmearn-stackjdksjdsfjdkofkdokodkojdj.pptx
mearn-stackjdksjdsfjdkofkdokodkojdj.pptx
aravym456
 
mearn-stack-new_ccvbhbhvgvgcdszsxdxfcf.pptx
mearn-stack-new_ccvbhbhvgvgcdszsxdxfcf.pptxmearn-stack-new_ccvbhbhvgvgcdszsxdxfcf.pptx
mearn-stack-new_ccvbhbhvgvgcdszsxdxfcf.pptx
aravym456
 
Meanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore ChandraMeanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore Chandra
Kishore Chandra
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
Balajihope
 
Progressive Web Apps and React
Progressive Web Apps and ReactProgressive Web Apps and React
Progressive Web Apps and React
Mike Melusky
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
Kasey McCurdy
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
HabileLabs
 
9 Best JavaScript Frameworks To Choose
9 Best JavaScript Frameworks To Choose9 Best JavaScript Frameworks To Choose
9 Best JavaScript Frameworks To Choose
Albiorix Technology
 
Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Review
netc2012
 
React vs Vue JS Explained | Vue JS vs React Which Is Better? | Vue JS for Beg...
React vs Vue JS Explained | Vue JS vs React Which Is Better? | Vue JS for Beg...React vs Vue JS Explained | Vue JS vs React Which Is Better? | Vue JS for Beg...
React vs Vue JS Explained | Vue JS vs React Which Is Better? | Vue JS for Beg...
Simplilearn
 
Single page application and Framework
Single page application and FrameworkSingle page application and Framework
Single page application and Framework
Chandrasekar G
 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdev
damianofusco
 
Web Development Today
Web Development TodayWeb Development Today
Web Development Today
bretticus
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the web
Sigma Software
 
Ad

Recently uploaded (20)

AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 

Intro to SPA using JavaScript & ASP.NET

  • 1. Intro to Single Page Applications Using JavaScript and ASP.NET Alan Hecht
  • 2. What is a Single Page Application? • The web equivalent of a desktop application • The application is written with HTML, CSS, and JavaScript • Unlike regular web sites, no page loads take place after initialization.
  • 3. Characteristics of a SPA • Launched from a single HTML page or view • The page is fairly interactive, like a desktop application • Portions of the page (sometimes very large portions) rendered client side by JavaScript
  • 4. Architectural Overview Browser - Web App HTML / CSS / JS Navigation / AJAX UI HTML / CSS / JS AJAX REST API - JSON Business Logic
  • 5. JavaScript in the Browser • Single thread handles all events, UI and nonUI • Synchronous events stop all further processing until done, which locks the UI • Asynchronous events are queued until callback function is called. Other events handled in the meantime
  • 6. Asynchronous JavaScript • Code is non-blocking. Callbacks aren’t invoked until code is done executing and the thread is waiting for events to execute. • Good analogy is the front window at the doctor’s office • Good for I/O intensive applications but not CPU intensive applications
  • 8. AJAX • Asynchronous JavaScript and XML (now use JSON instead of XML) • Browser makes an asynchronous HTTP request, callback function is called upon completion
  • 9. REST •Representational State Transfer •Building your web API using HTTP instead of on top of HTTP (like SOAP)
  • 10. REST •Four HTTP verbs used: GET, PUT, POST, and DELETE •Use URL path segments instead of query parameters or payload data
  • 11. REST Example HTTP GET /users - get a list of users HTTP GET /users/1 - get info for user id 1 HTTP POST /users - create a new user HTTP DELETE /users/1 - delete user id 1 HTTP PUT /users/1 - update user id 1
  • 12. JSON • JavaScript Object Notation • Collection of key-value pairs and lists of keyvalue pairs • Has replaced XML as a data format because of simplicity
  • 14. Structuring JavaScript Code • For non-trivial, interactive web apps, you’ll want to use a framework which at least has the concept of models and views along with how they get updated • A JavaScript framework architected with MVC, MVVM, MVP, or MV-Whatever helps structure the UI (will be using MVC as a ‘shorthand’ here)
  • 15. What about jQuery? • jQuery is great but alone doesn’t scale well for more complicated apps • For larger apps, you would likely wind up with data scattered about the DOM in ‘data-’ attributes and view logic tied to a particular HTML layout
  • 16. Client Side JavaScript MVC Frameworks Just pick one…
  • 17. JavaScript Framework Philosophy • Have lots of specialized frameworks that do one thing well, mix and match as needed (you’ll see this in Node.js) • But most of us are just trying to solve a business problem and don’t wish to engage in endless research • Nobody has won the client side JS MVC framework battle the way jQuery won with DOM manipulation & CSS selectors
  • 18. Scott Hanselman’s JavaScript Glossary • Great overview important and innovative client side JavaScript frameworks: http://www.hanselman.com/blog/TheBigGlossa ryOfOpenSourceJavaScriptAndWebFramewor ksWithCoolNames.aspx • Includes open source ASP.NET server side libraries that are innovative
  • 19. JS MVC Frameworks - How to Decide • At the end of 2013, the most popular as measured by Stack Overflow activity are: Backbone.js, Ember.js, Angular,js, Knockout.js, Dojo, and Ext.js • Best article I’ve seen which compares and evaluates JavaScript MVC frameworks while not making a recommendation is: http://www.funnyant.com/choosing-javascriptmvc-framework/
  • 20. TodoMVC.com • Sample Todo application written in each and every JavaScript Model/View/* framework • Gives a sense of how much structure and boilerplate code is needed to create a web app with a given framework
  • 22. Backbone.js •Contains the minimal set of models, collections, views, and URL functionality needed to build a web application •Good for experienced JavaScript developers
  • 23. Marionette.js • Built off of backbone.js • Reduces boilerplate code, especially in the views • Can be incorporated piecemeal
  • 25. Backbone.js Routing •Anything in a URL after the ‘#’ is for client side navigation representing a ‘view’. Classic example is AJAX pagination. •With a small, trivial application, a ‘switch’ statement will likely work. •For a more substantial application, something more formal which handles client side URL routes is usually needed
  • 26. Ember.js • Framework with an opinionated way of building web applications • Modeled after the Cocoa framework in iOS development and Ruby on Rails to a lesser extent • Designed for building desktop-like web applications
  • 28. Ember.js Templates • Client-side view templating which contains expressions that can be replaced with values • Templates can reside in separate files that are loaded and compiled.
  • 29. Ember.js & Discourse • Discourse is a large, open source, forum web application which uses Ember.js • Looks like a good non-trivial example of how to use Ember.js • Server side is Ruby on Rails, but just go to the app/assets/javascripts directory and you’ll be all set.
  • 30. Angular.js • Toolset for building the framework for web applications • What HTML would look like if it were designed for building web applications • Designed with testing in mind (dependency injection and plays well with testing tools)
  • 32. Angular.js Directives • Allow you to create custom HTML attributes, elements, or classes • The Angular compiler traverses the DOM on the client looking for pre-built or new directives.
  • 33. Angular.js Services • Functions that carry out specific tasks. Angular includes built-in services but custom ones can be created • Services added via dependency injection
  • 34. Knockout.js • Based on Model-View-ViewModel architecture just like WPF & Silverlight • Focuses on UI data binding • For apps bigger than a few pages, likely need other components like client-side routing
  • 36. Ext.js • Framework for building desktop-like applications • Works better for internal applications because it’s so heavyweight • Steep learning curve • First stable release back in 2007
  • 38. Dojo • Toolkit for building desktop-like applications • Extensive HTML widgets • Documentation not so great • First stable release back in 2007
  • 39. What about jQuery? • Ember.js depends on jQuery • Angular.js can use jQuery or include its own slimmed down version of it • Backbone.js, Knockout.js, Ext.js work with jQuery
  • 40. Building a REST API • Best options are ASP.NET Web API or WCF REST • Could use ASP.NET MVC or even an asmx web service if on Web Forms • The API can be (and often is) used native mobile applications as well.
  • 41. ASP.NET Web API • Designed to build APIs, not web sites • Unlike ASP.NET MVC, controllers return data and not views • Content type (i.e. JSON or XML) is negotiated, not specified, via HTTP ‘Accept’ header
  • 42. ASP.NET Web API Controllers • Controllers derive from “ApiController” instead of “Controller” like they do in ASP.NET MVC • HTTP methods bound to controller methods by start of method (“Get”, “Post”, “Put”, etc.) or with an attribute ([HttpGet], [HttpPost], [HttpPut], etc.)
  • 43. ASP.NET Web API - Routing • By default, the route is “api/{controller}/{id}”, and “api” is used to avoid collisions with ASP.NET MVC routing
  • 44. ASP.NET Web API - Example
  • 46. Back Button • Back button only works if the URL changes • Ember.js, angular.js, and backbone.js have some built in support • Can use HTML5 History API with knockout.js
  • 47. What about SEO? • Web crawlers at the end of 2013 don’t handle JavaScript • Content to the right of ‘#’ in the URL isn’t sent to the server, Google converts #! to an ‘_escaped_fragment_’ Huh?!?! • Experimental work with using Node.js to render the page on the server