HttpResponse extension: WriteJsonAsync Feb 5, 2020 This is a brief extension method for HttpReponse to write any object in JSON format. public static async Task WriteJsonAsync(this HttpResponse httpResponse, object obj, CancellationToken cancellationToken = default) { httpResponse.ContentType = MediaTypeNames.Application.Json; var json = JsonConvert.SerializeObject(obj); await httpResponse.WriteAsync(json, cancellationToken); } Please enable JavaScript to view the comments powered by Disqus.