0

I would like to know which is the best way to display images using ajax calls.

I get the data stored in the database as a byte[] array and then I send the data as base64 string to the view using ajax.

With small images this work fine but when there are big size images, I get an internal server error in the response.

And I´m wondering why?

The error message is: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

List<string> images = new List<string>();
foreach (var student in students)
{
string base64String = System.Convert.ToBase64String(student.StudentImage, 0, student.StudentImage.Length);     
images.Add(base64String);
}

and then the public ActionResult returns this.

 return Json(images.ToArray());

with small images works fine the problem is with big size images.

gmartinez
  • 11
  • 3

0 Answers0