Quote:
Context.Response.AddHeader("content-length", res_data.Length.ToString());
This line is the problem.
The content length header specifies the number of
bytes in the response body. You are sending the number of
characters instead.
That mostly works when you send English text, because that only tends to use characters which can be represented as single bytes. But when you're returning characters which require multiple bytes to encode them, the string length will be less than the number of bytes.
UTF-8 - Wikipedia[
^]
Most browsers will truncate the response body when it reaches the number of bytes specified in the content length header, which is why you're getting an incomplete response.
The simplest option would be to remove the line which sets the content length header. Otherwise, you're going to need to know exactly how many bytes you're sending:
string res_data = js.Serialize(dta);
byte[] res_bytes = System.Text.Encoding.UTF8.GetBytes(res_data);
Context.Response.Clear();
Context.Response.ContentType = "application/json; charset=utf-8";
Context.Response.AddHeader("content-length", res_bytes.Length.ToString());
Context.Response.BinaryWrite(res_bytes);
Context.Response.Flush();