Calling an api and deserializing the returned json into a type is something I have to do quite often.

I used to use the following:

If the JSON returned is large, we’ll often get an Out Of Memory Exception

From the docs

To minimize memory usage and the number of objects allocated, Json.NET supports serializing and deserializing directly to a stream.

To rectify this, we can instead use Streams


In my example, where the JSON has a nested ‘result’ element, you’ll also need a class to represent this (see TypeContainingMyResult above)

My current contract involves working on a project based on Umbraco.

Unit testing Umbraco, can be a bit tricky, especially given the existence of the static ApplicationContext.Current.Services class, which contains handy references to the Umbraco services – provided by a static type! We can’t mock this.

So, I created a little wrapper around this that would allow us to mock the returned service, via an interface

In the implementation, I use reflection to return the underlying service from ApplicationContext.Current:

I ran into this issue when deploying an application that uses the DynamicPDF Rasterizer.


After emailing support, who got back to me within the promised 24 hours, they offered some good suggestions.

The solution for me was to use the installer provided on their download page, which in turn installs the pre-requisites (Visual C++ distributable)
Secondly, I changed the reference in my project to the x64 version of the binary, and changed the build platform target



.net project unit test naming

Just wanted to do a quick post on unit test method naming, in particular with .net projects;

Most test suites I come across are title cased:

This annoys me. I find long method names hard to read, and easy to miss detail


is not a readable as:

Removing $id from JSON returned by WebApi

If you’re using the default JSON formatter (ie- haven’t set another one up) your outputted JSON may look something like this:

Notice the $id element appearing.

What you see as $id is actually a reference used to preserve the handle so that if the element repeats somewhere in the output, it wont print a repeat pf the data, it will just set a “$ref” property of the duplicate to the “$id” of the original.

You can disable this by adding the following code to Application_Start method in the Global.asax file:

Page 1 of 4