ServiceStack v4.0.35

We're ending 2014 with a short release cycle primarily focused on a polished and fixes Release, ready for before everyone gets back at work - re-energized for a Happy New 2015 work year :)

New TechStacks LiveDemo!

We've been gradually refining our modern AngularJS and React Single Page App VS.NET templates which represents what we believe to be the optimal formula for developing future .NET-based JS Apps - utilizing a best-of-breed node.js, npm, bower, grunt/gulp build system.

To this end we're developing new Single Page Apps alongside to further refine these VS.NET templates and demonstrate their potential in using the pre-configured Grunt tasks to manage the full iterative client/server building, optimization and deployment dev workflows.

We're happy to be able to preview the latest Live Demo built on the AngularJS App VS.NET template in: https://techstacks.io

TechStacks

TechStacks is a modern AngularJS CRUD App that lets you Browse and Add Technology Stacks of popular StartUps. After Signing in you can add your own TechStacks and favorite technologies to create a personalized custom 'feed' to view Websites and Apps built with your favorite programming languages and technologies.

TechStacks is based on a Bootstrap template with client-side features:

  • HTML5 Routing to enable pretty urls, also supports full page reloads and back button support
  • Same Services supporting both human-readable Slugs or int primary keys
  • Responsive design supporting iPad Landscape and Portrait modes
  • Preloading and background data fetching to reduce flicker and maximize responsiveness
  • Disqus commenting system
  • Chosen for UX-friendly multi combo boxes

and some of TechStacks back-end features include:

TechStacks is a good example of the experience you can get running a packaged ServiceStack/AngularJS App on modest hardware - techstacks.io is currently running on a single m1.small AWS EC2 instance and db.t1.micro RDS PostgreSQL instance that hosts all Live Demos.

View the Source

Checkout the Source Code for TechStacks for the full details to see how it's built. The project also includes an example client layout for structuring larger AngularJS projects in an extensible layout files and folder structure:

HTML5 Routing and Full-page reloads

One of the disadvantages of Single Page Apps is having to resort to hash-style #! url suffix hacks to prevent JavaScript apps from making full-page reloads. By utilizing AngularJS's HTML5 mode we can take advantage of modern browsers support for HTML5 History API to retain the optimal pretty urls (we'd have if this were a server generated website) whilst still retaining the responsiveness of JS Apps which are able to load just the minimum content required, i.e. instead of waiting for the full page rendering of Server generated pages and their resource dependencies to be loaded again.

ServiceStack has great support for these modern-style SPA's which lets you specify a fallback handler for HTML page requests with un-matched routes to return the same /default.cshtml home page so AngularJS is able to handle the request and perform the same client-side routing it would've had the url been navigated from within the App - using the AppHost configuration below:

base.CustomErrorHttpHandlers[HttpStatusCode.NotFound] = new RazorHandler("/default.cshtml");

This lets you re-use pretty client-side routes like:

And allow deep-link support for full round-trip requests (i.e. outside of AngularJS) - where since /tech/servicestack doesn't match any custom Server routes, ServiceStack instead responds with the above /default.cshtml Razor View. At which point AngularJS takes over and navigates to the internal route mapping that matches /tech/servicestack.

To get the latest AngularJS and React.js App templates download the latest ServiceStackVS VS.NET Extension

ServerEvents now supports Multiple Channels per subscription

To ensure each Client only ever needs 1 ServerEvents subscription, subscriptions now support subscribing to multiple channels. Multi Channel Support is fully implemented in all JavaScript ServerEvents and C#/.NET ServerEvents Clients as well as both back-end InMemory and Redis ServerEvents providers.

The API remains similar to the previous Single Channel Routes where in addition to subscribing to a single channel:

/event-stream?channel=Home

Clients can also subscribe to multiple channels:

/event-stream?channel=Home,Work,Play

If preferred, clients can also use the more readable ?channels= plural variable name

And the above example again using the C#/.NET ServerEvents Client:

var client = new ServerEventsClient(BaseUri, "Home");

var client = new ServerEventsClient(BaseUri, "Home", "Work", "Play");

Multi-Channel subscriptions works conceptually similar to having multiple "single channel" subscriptions where multiple Join/Leave/Message events are fired for events occurring in each channel. For more details on this checkout the multi-channel ServerEvents tests.

Chat Apps now support multiple Chat Rooms

With this feature, we can now create Chat Apps that support multiple Chat Rooms using only a single ServerEvents subscription:

React Multi-Channel Chat

Multi-Channel React Chat preview

Surprisingly it only took a small amount of code to add support for multiple chat rooms in all the different Chat Apps which now all support Multiple Chat rooms:

Should you want to run the previous "Single Room" Chat Apps, they're available in the single-channel branches:

Multi-Channel support is mostly backwards compatible where all Chat Apps can be run as-is when upgraded to use the latest ServiceStack v4.0.35+ - but it does require upgrading both v4.0.35 Client and Server libraries together.

Minor Changes and Fixes

Rest of this release was focused on minor features, changes and fixes:

Framework Changes

  • Custom HTTP Handlers now execute Global Request Filters 709fb73
  • Static Default html pages (e.g. default.html) are served directly from root instead of being redirected to static file - Behavior is now in-line with default.cshtml in Razor Support 5b5d7fa
  • StaticFileHandler HTTP Handler is now re-usable VirtualNode for returning Static Files 8571ecd
  • Original C#/.NET Exception is now accessible as InnerException in wrapped HttpError 42d5976
  • Added overridable IDbConnectionFactory and IRedisClientsManager properties in Service base class c18215b
  • Add .woff2 to Config.AllowFileExtensions white-list aa1e93a
  • Changed all methods in MVC ServiceStackController base class to protected to prevent MVC Controller Factories from assuming their MVC Actions eff11c
  • Added Remove Plugin and Debug Link API's 9002d48
  • Added Retry logic on Concurrent Update collisions in OrmLiteCacheClient aa6d62c
  • Added Runtime Attribute Filter example 355365b
  • Add support for implicit querying of enums in AutoQuery b5d2477
  • Handle Retry Exceptions during on ServerEventsClient reconnections 7833cd8
  • Added AppHost.GetCurrentRequest() to allow different AppHosts to return the current HttpContext 7cbadda
  • Fixed NRE during max pool-size overflow handling in RedisManagerPool c94eedd

Auth Changes

  • IAuthRepository.CreateOrMergeAuthSession() now returns the merged IUserAuthDetails f2383ff
    • OnRegistered() callback now fired for successful first-time OAuth requests (in addition to /register Service)
  • Added AppHost.OnSaveSession() to allow custom logic whenever a User Session is saved to the Cache 002a4eb
  • New Dictionary<string,string> Meta added to allow custom Auth params on Authenticate during Authentication 4d339c1
  • New Config.AddRedirectParamsToQueryString option added to change redirect params to be added to QueryString instead of hash # params fea60fa
  • NHibernateUserAuthRepository.GetCurrentSession() is now overridable to customize NH Session Initialization 7249c9a

MQ Changes

  • Added QueueNames.IsTempQueue() API to determine if a MQ name is a Temp Queue even when custom naming conventions are used c3ee3d0
  • Pass IMessageHandler in custom MQ Error Handlers so Nak's can be sent from same client that received the message 3be2e3f

OrmLite Changes

  • SqlProc no longer disposes IDbCommand before returning it 9e71480
  • Fixed SingleAsync API to call correct internal API b23410
  • Added support new Multi-Column OrderBy Descending API's 33292ef
  • Add support for ConvertToList<T> to handle Scalars as well 4290229

ServiceStack.Text Changes

  • Add support for Dates in yyyyMMdd format a752f2a
    • Add New DateTimeSerializer.OnParseErrorFn fallback can be used to handle unknown Date Formats
  • Added convenient Task.Success() and Task.Error() extension methods for non-generic Task b17866a
  • PCL version of GetPublicProperties() now only return instance (non-static) properties dbe1f83

Dependencies Updated

  • FacebookAuthProvider upgraded to use v2.0 of Facebook's API
  • Swagger UI updated latest version
  • Memcached updated to 0.57
  • FluentNHibernate to 2.0.1.0