Pro Single Page Application Development: Using Backbone.js and ASP.NET

Book description

One of the most important and exciting trends in web development in recent years is the move towards single page applications, or SPAs. Instead of clicking through hyperlinks and waiting for each page to load, the user loads a site once and all the interactivity is handled fluidly by a rich JavaScript front end. If you come from a background in ASP.NET development, you'll be used to handling most interactions on the server side. Pro Single Page Application Development will guide you through your transition to this powerful new application type.

The book starts in Part I by laying the groundwork for SPA development. You'll master some JavaScript techniques that will come in useful later on, and get to know the building blocks of a single page application, including modules, routing and MV* frameworks.

In Part II, you'll build the client for your application. This is where the magic happens, as the authors take you through the process step by step. Backbone.js is the ideal library for demonstrating SPA development in practice, but you can apply the same principles with other frameworks in your future applications. Part III takes you through the process of building the server side of your application using ASP.NET Web API, and hooking up the two parts of your application to create a working whole.

SPA development also comes with its own particular challenges, including tracking history, user interface performance, and how to handle search engine optimization. In the final chapters, the authors guide you through some of these issues and advanced techniques and finish by showing you how to deploy your application. As SPAs become the de facto standard of web application development, the in-depth Pro Single Page Application Development will be your one-stop shop for creating fluid, modern applications on the web.

What you'll learn

  • Reasons to master single page application development

  • SPA architecture and key concepts

  • Mastering modular JavaScript development techniques

  • Meet the popular Backbone.js library and how to use it to build an SPA

  • Create a back end with ASP.NET Web API and consume it from your SPA

  • How to unit test and performance tune your application

  • Overcome the difficulties of search engine optimization in single page applications

  • Who this book is for

    This book will suit professional web developers familiar with HTML and JavaScript. Readers will need experience with .NET and C# in order to follow along with Part III, which covers back end development with ASP.NET Web API.

    Table of contents

    1. Title Page
    2. Dedication
    3. Contents at a Glance
    4. Contents
    5. About the Authors
    6. About the Technical Reviewers
    7. Acknowledgments
    8. Introduction
    9. PART I: The Road to Single Page Application Development
      1. CHAPTER 1: Introducing Single Page Applications
        1. How the Web Has Evolved
        2. The Ajax Revolution
        3. HTML5 and JavaScript
        4. The Mobile Web and JavaScript
        5. JavaScript Preprocessors
        6. Comparing Application Types
        7. So What Is an SPA?
        8. Why SPA Development?
        9. Summary
      2. CHAPTER 2: JavaScript for SPAs
        1. A Little JavaScript History
        2. Functions in JavaScript
        3. JavaScript Scope
        4. Immediate Function Execution Expressions
        5. Working with Object-Oriented JavaScript
        6. Creating JavaScript Namespaces
        7. Closures and Encapsulation
        8. JSON
        9. ECMAScript and Its Impact on Future Code
        10. Summary
      3. CHAPTER 3: Modular JavaScript Development
        1. The Façade Pattern in JavaScript
        2. Modules to the Rescue
        3. Different Options to Create JavaScript Modules
        4. What Is the Asynchronous Module Definition?
        5. The RequireJS Library
        6. Summary
      4. CHAPTER 4: SPA Concepts and Architecture
        1. Main SPA Building Blocks
        2. JavaScript Libraries
        3. MV* in the Front End
        4. Routing in an SPA
        5. Leveraging HTML5 JavaScript APIs
        6. Client-Side Template Engines
        7. Server Back End API and REST
        8. SPA Architecture
        9. Summary
    10. PART II: Building the Front End
      1. CHAPTER 5: Getting Started with Backbone.js
        1. What Is Backbone.js?
        2. Models
        3. Views
        4. Collections
        5. Events
        6. Routing
        7. Backbone.js and RequireJS
        8. Summary
      2. CHAPTER 6: Creating a Single Page Application Step by Step
        1. Choosing an IDE
        2. Crafting the Models
        3. Adding Collections
        4. Creating a Data Service and Generating Mock Data
        5. Adding Front-End Routing
        6. Creating Views
        7. Summary
    11. PART III: Building the Back End
      1. CHAPTER 7: Creating a Back-End Service with ASP.NET Web API
        1. Introduction to HTTP-Based Services
        2. ASP.NET Web API Basics: Routing, API Controllers, and Actions
        3. Attribute-Based Routing
        4. The HttpResponseMessage Class
        5. Handling Exceptions
        6. Validating the Input
        7. Summary
      2. CHAPTER 8: Implementing HTTP Concepts with ASP.NET Web API
        1. Content Negotiation
        2. Caching
        3. Resource Versioning with ETags
        4. Uploads and Downloads
        5. Summary
      3. CHAPTER 9: Communication Between Front and Back End
        1. Using Ajax to Communicate with the Server
        2. The Promises Pattern
        3. Backbone.js Ajax Support
        4. Updating TheAgency
        5. Working with Other Communication Options
        6. Summary
    12. PART IV: Advanced SPA Topics
      1. CHAPTER 10: JavaScript Unit Testing
        1. Unit Testing in the Front End
        2. What Is TDD?
        3. What Is BDD?
        4. Jasmine Library
        5. Setting the Environment
        6. Creating Suites and Specs
        7. Using Spies
        8. Testing Asynchronous Code
        9. Writing Tests for TheAgency Project Using Jasmine
        10. Summary
      2. CHAPTER 11: SPA Performance Tuning
        1. Optimizing the Front End
        2. Optimizing the Server (Back End and Network)
        3. Summary
      3. CHAPTER 12: Search Engine Optimization for SPAs
        1. The Search Engine Crawler
        2. The Problem with SPAs and SEO
        3. Options to Optimize Your SPA for SEO
        4. Summary
      4. CHAPTER 13: SPA Deployment
        1. Deployment Techniques
        2. Continuous Deployment
        3. Deploying to the Cloud
        4. Summary
    13. Index

    Product information

    • Title: Pro Single Page Application Development: Using Backbone.js and ASP.NET
    • Author(s):
    • Release date: May 2014
    • Publisher(s): Apress
    • ISBN: 9781430266730