asp.net.netsingle-page-application

Difference between Single Page Application and Web Application.


What are difference between Single Page Application and Web Application. What are advantages and disadvantages. When SPA should be used and when Web application should be used


Solution

  • See this answer. An overly simplified comparison, in terms of development effort, is

    Multi page application:

    1. User action embodied in HTTP request (e.g. HTTP POST, HTTP GET)
    2. Request is handled, server responds with HTTP page

    Drawbacks: requires many pages just to respond to every user action (e.g. add item to list, update form data), whereas in a SPA data binding can do much of the work of updating the view for you. Secondly, it's the responsibility of the web application to maintain state which is otherwise lost between full page requests. In contrast, the SPA can maintain its state in memory, between XHRs without additional work while the browser stays on the same page.

    Single page application (SPA):

    1. configure routing on both client and server side
    2. code "controllers" on both client and server
    3. initialize the framework on client
    4. Handle user actions in JavaScript
    5. Handle XHR request/response

    These are just typical steps I've noticed in developing both single- and multi-page apps, and this doesn't necessarily or extensively represent all cases.

    To develop SPAs, frameworks such as AngularJS are highly encouraged and highly opinionated, an advantage of which is guidance on structuring your client-side JavaScript.

    Where multi page applications respond to user actions with full page loads, single page applications by definition are limited to 1 page (otherwise they'd be multi page) and instead rely on XHR.