public static void JsonContent(this HttpListenerResponse response, object contentObject)
        {
            var jsonText = SimpleJson.SerializeObject(contentObject); //doesn't work for dynamic

            //var jsonText JsonConvert.SerializeObject(contentObject); //handles dynamic
            response.ContentType("application/json").Content(jsonText);
        }
Example #2
0
        public static void JsonTextContent(this HttpListenerResponse response, string value)
        {
            response.ContentType("application/json");
            var buffer = Encoding.UTF8.GetBytes(value);

            response.ContentLength64 += buffer.Length;
            response.OutputStream.Write(buffer, 0, buffer.Length);
        }
Example #3
0
        public static void JsonContent(this HttpListenerResponse response, object contentObject)
        {
            var jsonText = JsonConvert.SerializeObject(contentObject);

            response.ContentType("application/json").Content(jsonText);
        }