atic void RenderJSON(this Controller c, object data, string contenttype, Encoding encoding)
{
HttpResponseBase response = c.HttpContext.Response;
if (!string.IsNullOrEmpty(contenttype))
{
response.ContentType = contenttype;
}
else
{
response.ContentType = "application/json";
}
if (encoding != null)
{
response.ContentEncoding = encoding;
}
if (data != null)
{
DataContractJsonSerializer sr = new DataContractJsonSerializer(typeof(object));
sr.WriteObject(response.OutputStream, data);
}
}
}
}