ASP.NET SPA
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
The ASP.NET Single Page Application (SPA) is a new feature in the ASP.NET MVC 4 Beta preview. It provides a better end-to-end experience for building applications with significant client-side interactions using JavaScript. It includes:
-
A set of JavaScript libraries for richer local interactions with cached data
-
Additional Web API components for unit of work and DAL support
-
An MVC project template with scaffolding to get started quickly
The main SPA documentation is on the ASP.NET Web site and can be access at ASP.NET Single Page Application. Here are some remarks, for convenience, on the three SPA components itemized from that site.
The JavaScript libraries include existing popular ones such as Knockout and History and a relatively new library called Upshot (formerly previewed as RIA/JS). Together they support presentation and editing of data across a set of pages that interact with local and remote data. They illustrate one prescriptive pattern of using distinct libraries together. You could also use them independently or replace one or more of them. For example, Upshot could be used with JsViews or jQuery UI or ISV controls and jQuery could be replaced with XUI. Some of the replacements may require some adaptation via a small library.
DataController on the Server
On the server-side, a new class called DataController which derives from ApiController, provides support for insert, update and delete operations in a unit of work with transaction support and automatic validations. It also provides a way to get the total count for paging along with the first page. It also provides a foundation for Data Access Layer-specific implementation of the above features. For example, DbDataController<TContext> is a DataController that implements the above for Entity Framework Code First style of data access.
Single Page Application MVC Project Template
A new MVC project template for Single Page Application provides an educational tool and a way to start quickly. It includes scaffolding to generate a skeletal app that includes a DataController, optionally an Entity Framework DbContext and the scripts for basic query and edit tasks (CRUD operations). The template also includes a sample model class that you could use as is or replace with your favorite one to get started.