// By the time we get to WriteToStreamAsync, it's too late to set the Content Headers public override Task WriteToStreamAsync(Type type, object value, Stream stream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken) { if (!typeof (IEntity).IsAssignableFrom(type)) return Tasks.Empty; var objectToSerialize = SerializeSirenEntity((IEntity)value); return stream.WriteJsonToStreamAsync(objectToSerialize, cancellationToken); }