15 January, 2017

EPIServer error: Real-time updates not working

So - if you see this error dialogue when starting the admin part of EpiServer; you most likely are not having your webserver configured correctly (as the error suggest ;-)). To reflect updates to the database - the system is using websockets to communicate that to the webclient rendering the administration website.

Therefore - this is due to a missing WebSocket configuration/installation on the webserver (IIS). To remedy this open Programs and Features on Windows (Server or Client) and add WebSocket as seen below.

That is what it takes.

06 December, 2016

The keyboard guide when running Windows on a Mac (using Parallels)

So - even I love working on the MacBook - it still is somewhat difficult to remember how the default mapping is when constantly switching between Mac and Windows interchangeably.

As a point of reference to myself - and for others blessed with Parallels; here is the list of commands.

Requested Key Keyboard Combination
{ Shift (left) + Alt (right) + 8
} Shift (left) + Alt (right) + 9
/ Shift (left) + 7
\ Shift (left) + Alt (right) + 7
@ Alt (right) + @
| Alt (right) + i
[ Alt (right) + 8
] Alt (right) + 9

30 October, 2016

Building a single (cloud-based) backend supporting multiple mobile apps

Being the architect as well as hands-on implementor of a real-life system supporting a number of concurrent mobile applications (in both Google Play and Apple AppStore); I’ve learned a thing or two during the development and evolution of this system (now in gen. 3). What are my take-aways from this process? And what are the pit-falls?

Before we dive into the meaty part - maybe you should ask: why are we looking for one backend-system and not a bespoke and optimized backend-system supporting each specific mobile application? Wouldn’t that be a better approach? Well - I think it goes without saying; but the cost and effort of maintaining several different systems when you can do with just one aludes to a pretty good reason seen through my set of financial eyes.

Obviously - there are limits to how different these mobile (client) applications can behave and still being supported by the same system (you can’t mix automobile apps with fitness apps, can you?), but given that most companies tend to produce applications within the same realm or domain - it does make sense in a company-setting to strive for an as simple and generic system as possible. So that’s what we are trying to realize.

Before we move on - the audience to benefit most from this post will primarily be system architects, secondly developers as it becomes rather technical as we walk through the system...


The overarching goal is to have a system that can support not only your current applications, but also new applications that you do not yet know. Furthermore, the system should be able to respect different “twists" the mobile applications can exhibit. How can you realize this goal?


An idea of the overall picture is required before diving into the specifics. You need to be able to see that before you can appreciate the details. The overall picture looks like this:

System components


The graphics above can seem like a lot of arrows, but the key concept is that there is a Token System responsible for supplying the mobile Clients with a Token provided the credentials they present are accepted. This token is next presented in every call to the WebAPI (using the HTTP Auth-header). The WebAPI in this scenario constitutes the business logic of the system and is implementation-wise; a REST-API.

Given that the token obtained is part of every call to the WebAPI, the WebAPI can remain stateless and from the Token-value itself establish which context it is being invoked (context = App A or App B or…).

As the task of validating whether a given set of credentials are valid, by design is kept away from the business logic (WebAPI), the business logic can remain indifferent as to how the User is identified. It can simply rely on the simple fact that a token is present every time it is being called. An added advantage to the separation of concerns here is that the business logic also does not care whether credentials are coming in in the form of username/password, facebook integration, Google Login or an X509-certificate. All this is the responsiblity of the Token System.

Business Logic

The business logic should be able to adapt to the mentioned deviations in the clients requirements. Maybe when the caller is App A it should return Users with first name starting with Joe, whereas when being called in the context of App B it should return Users with 5 records in the database? This is where factories and plugins are relevant. Actually normal and standard object-oriented design, but shielded behind interfaces and WebAPIs.


Most mobile applications benefit from some form of push notifications. It has by now become an expected behaviour that Apps interact with the user by notifying him of relevant and contextual important information. Sending out notifications to Android phones or IOS phones relies on 2 different systems (FireBase by Google and Apples Push Notification Services), although the message itself is JSON in both cases. To realize a simple sub-system that is capable of sending out messages to the phones, also here - this is kept to a dedicated system with these capabilities.


Now that we have an idea of the overall picture (how the architecture is layed out and who is responsible for what); we can move on to a more technical part of this post. The implementation in this case is built on the Microsoft stack - so the following technologies are used:
  • MEF (adaptation to various contextual changes)
  • WebAPI 2 (interface, REST API)
  • Entity Framework (database access)
  • Swagger IO (documentation of REST API)
  • SQL (standard RDBMS)
  • Azure (hosting)
  • C# (runtime 4.6)

MEF and logic adaptation

To appreciate and fully understand the choice and usage of MEF - you need to understand how that works. MEF is an injection based implementation from MS that allows you to build loosely coupled implementations. As seen below - the interface implementation is found in 3 different assemblies (one default implementations and two supporting potential overrides for each context). Loading of the implementation is performed by an ObjectFactory found in the interface assembly. It will look in the /bin directory for implementations supporting a given interface.
To allow the MEF system to determine which implementation it should load - it uses metadata found as decoration on the various implementations. By default - it will load the "DEFAULT" implementation, but if an implementation is found with specific support for a context (e.g. App A) - this is loaded instead and returned to the webapi.


The interface the mobile app developer is faced with is REST based. To make it as easy to consume as possible it follows the conventions used by most REST-based API nowadays. It makes heavy use of the standard HTTP-verbs (GET, POST, PATCH, DELETE) and makes the URI part of the interaction of the resources.


An attempt to invoke any method requires the Client to present a valid security token as previously mentioned. If one is not present - the system refuses to execute and terminates the request (by design). This is manifested by the WebAPI as a standard HTTP-error code = .405

As seen from the image above - the web method is decorated with metadata that suggests that this method cannot be called without presenting a AuthToken (security token).

Hosting (Azure)

This section actually could be worth an entire blogpost in its own right (and I might write one), but simply put - this is hosted in the cloud to realise the scalable nature of Azures engines.


The minute I see a word document "constituting" documentation on a live system; I become suspicious. How relevant and current is this "documentation"? Does it reflect what Im seeing when programming against this webAPI? To remove that problem, Swagger IO is used to document the API. Swagger is a superior reflective toolset that generates documentation when you press F5 (refresh) in your browser.

It will generate documentation like you see here:

Final thoughts and comments

Finally - before you go all "religious" on me - this is just one route to the goal. There are other ways. It just happens to be the approach I found to be the better one ;-)

Mobile Apps



20 September, 2016

How to remove the Dashboard on a Mac

If you are just as annoyed as I am with the useless Dashboard app on a Mac - there is one effective way of killing it.

Open a terminal window and write:


defaults write com.apple.dashboard mcx-disabled -boolean YES && killall Dock


defaults write com.apple.dashboard mcx-disabled -boolean NO && killall Dock

14 September, 2016

Running Xcode 7.3.1 and Xcode 8.0 on the same machine

If you need to be running Xcode 7.3.1 and 8 together (as I am!); you can not install them just like that. You need to fiddle a bit with the apps to have them work together.

  • Download the Xcode 7.3.1.dmg file from apple developer portal.
  • Download the Xcode 8.xip file from apple developer portal.

Once you’ve done that, you can install version 7.3.1 into “applications”:

Xcode 7.3.1

  1. Double click the .dmg file to open the “drive” it represents.
  2. Drag the Xcode icon into “application"
  3. Rename the resulting xcode.app in “applications" to xcode_7.app

Xcode 8

Now - the turn comes to Xcode 8. You unzip the .xip file and drag into Applications the resulting xcode.app file (it’s version 8).

You now have 2 versions of Xcode on your Mac and start them independently.

  • Xcode_7.app
  • Xcode.app

The reason I’m not renaming the XC8 version is due to future updates coming from Apple. I’m not sure how they search for apps locally during an update process...

13 September, 2016

Enums in C# vs. Swift - how to

The concept of a “flagged enum” is quite a powerful one as it allows you to express multiple things with just a simple number (integer). Coming from a .NET background - the ease of flagged enums found in C# is not that easily found in Swift I’ve come to realize. The expression in Swift is somewhat different and honestly a bit difficult to grasp.

Let’s give it a try:


In C# you express an enum like this:

public enum SecurityLevel : Int{
	case NoAccess = 0
	case Employee = 1,
	case LineManager = 2,
	case DivisionManager = 4,
	case RegionalManager = 8,
	case CountryManager = 16}

This constructed example serves a purpose like:

var person = new Person();
person.AccessLevel = 3 //meaning access as Employee AND LineManager

This will allow us to model a Person with multiple access levels (security levels) with just a single integer. An easy way to store in the backend database as well!


So - how does this look in Swift?

public struct securityLevel : OptionsSetType {
	let rawValue : Int
	static let noAccess = securityLevel (rawValue: 0)
	static let employee = securityLevel (rawValue: 1 << 0)
	static let lineManager = securityLevel (rawValue: 1 << 1)
	static let divisionManager = securityLevel (rawValue: 1 << 2)
	static let regionalManager = securityLevel (rawValue: 1 << 3)
	static let countryManager = securityLevel (rawValue: 1 << 4)

Quite a different beast, ey? How can this be the same you are thinking?
The strange << operator is called a bitwise left shift operator and and actually does what it says - it moves all bits in the array to the left by the number specified.

Looking at the securityLevel struct again, we have:

setting the value to noAccess:
0|0|0|0|0|0 = 0
setting the value employee:
0|0|0|0|0|1 = 1
setting the value lineManager:
0|0|0|0|1|0 = 2

combining the values (employee AND lineManager)
0|0|0|0|1|1 = 3

So the left shift stuff is actually initializing the struct with the value of 1, and then it moves all bits a number of slots to the left to end up with a whole new number. In our example with the combined employee and lineManager - we will see first the employee being set (rawValue:1 <<0)

  • init with 1 -> 0|0|0|0|0|1
  • next move it 0 places to the left -> 0|0|0|0|0|1
  • end result = 1

Next is the lineManager value (rawValue: 1 << 1):

  • init with 1 -> 0|0|0|0|0|1
  • next move it 1 places to the left -> 0|0|0|0|1|0
  • end result = 2

When combining the operations (employee AND lineManager) you are actually just performing the above operations in sequence ending up with the value 3.

Easy to understand? Not so much ;-)

23 August, 2016

Essential (developer) tools: A biased list – 2016 Mac version

I have been doing a collection of tools relevant to a life as a developer on .NET, but having recently swiched to Mac - here is the same (current) list as an XCode developer.
Development tools:

Quite a short list, but life in Mac world is simple (remember: simple != easy)