This project is read-only.

Advanced Json Communication and Single-Page applications

Requires MVCControlToolkit.Controls.Core.x.x.x.js, MvcControlToolkit.Bindings-x.x.x, knockout.x.x.x.js, knockout.mapping.x.x.x.js,  MvcControlToolkit.Utils-x.x.x.js, and MVCControlToolkit.JsQueryable-x.xx.min.js.

MvcControlToolkit.Utils-x.x.x.min.js must be placed AFTER knockout.x.x.x.js, since it checks if knockout.js features have been installed.

Attention: using ApiControllers to expose IQueryables requires the Queryable attribute that now is included in the nuget package Microsoft.AspNet.WebApi.OData. However, this package is automatically installed when selecting a WebApi project project type if you have installed the ASP.NET and Web Tools 2012.2 update.

For a tutorial on using OData and ApiControllers returning IQueryables, please see here.

The Mvc Controls Toolkit includes tools to handle advanced Json communication with a server to build higly responsive applications that minimize the bandwidth and the round trips with the server.

More specifically:

  • The implementation of the abstract class mvcct.Queryable contained in the MVCControlToolkit.JsQueryable-x.xx.min.js file make possible to build complex queries with a fluent Linq like syntax either against oData sources or against javascript data cached in the client (this way the client can work also offline). All implementations of mvcct.Queryable share the capability to import query data from the sorting, filtering, and paging controls of the Mvc Controls Toolkit. oData sources can be implemented by exposing an IQueryable with an ApiController.
  • The retrievalManager class intercepts events triggered by all queries related Mvc Controls Toolkit controls (like pagers, and sort buttons), and transform them into commands for an mvcct.Queryable object that is passed in its constructor.
  • The SafeQuery and HttpSafeQuery IQueryable implementations which are contained in the MVCControlsToolkit.Linq namespace, work as wrappers around any IQueryable protecting it from unwished dangerous queries. The acceptable queries are easily defined with the CanSortAttribute. This way the SafeQuery and HttpSafeQuery with the help of the all security options of the QueryableAttribute allow the exposition of big amounts of data as IQueryable on the web.
  • The updatesManager javascript class contained in the MVCControlToolkit.JsQueryable-x.xx.min.js file allows the batch pocessing of related entities on the client and the subsequent submission of all changes to the server.  Just the change set is sent to the server, thus saving bandwidth.  Client and server are kept synchronized automatically: errors are returned to the client as needed and handled smartly, keys created on the server are automatically returned to the client. Everything is done in a completely transparent way. There are no limitations on the sever method that receives the updates: it can be any Mvc Action method, or any WebApi post method. Moreover, it can be connected directly to a DB, to an EF model or to a complex business layer.
  • The Updater<T, U> and ChildUpdater<T, U> classes help to handle the change sets once they are received by the server. However, their use is not obligatory.

For a quick start on advanced json communication and single-page applications refer to the tutorials:


Protect your IQueryable from malicious users with SafeQuery and HttpSafeQuery

mvcct.Queryablemvcct.oDataQueryablemvcct.upshotQueryable, and mvcct.localQueryable

Easy filtering, paging, and sorting with the retrievalManager class

Batch processing on the client with the updatesManager class

Last edited Jun 22, 2014 at 11:43 AM by frankabbruzzese, version 16


No comments yet.