/// <summary> /// output object in json /// </summary> public static void OutputJson(HttpResponse response, object result, int cahceMinutes, string jsonp) { bool isJsonp = StringUtil.HasText(jsonp); response.ContentType = isJsonp ? "application/javascript" : "application/json"; // fix content type bug HttpContext.Current.Items["_ContentType_"] = response.ContentType; if (!isJsonp) { ServerUtil.AddCache(response, cahceMinutes); } else { ServerUtil.AddCache(response, -1); } string r = new Kiss.Json.JavaScriptSerializer().Serialize(result); if (isJsonp) { r = string.Format("{0}({1})", jsonp, r); } response.Write(r); }
private void SendOutput(HttpResponse response, string contentType, byte[] output) { ContentType = contentType; response.ContentEncoding = Encoding.UTF8; ServerUtil.AddCache(60 * 24 * 90); response.BinaryWrite(output); }
private void WriteBytes(byte[] bytes, HttpResponse response, string contentType) { if (bytes == null || bytes.Length == 0) { return; } ContentType = contentType; ServerUtil.AddCache(60 * 24 * 90); response.BinaryWrite(bytes); }