我应该如何从控制器动作c#asp.net-mvc-2返回一个图像?

我正在从像下面的byte[]构建图像。

 public FileContentResult GetEmployeeImage(int empId) { MemoryStream ms = new MemoryStream(byteArray); Image returnImage = Image.FromStream(ms); return returnImage;//How should i return this image to be consumed by javascript. } 

我想通过控制器操作方法将此图像返回到浏览器,因此它可以被我的javascript代码使用并显示在浏览器中。 我该怎么做?

您不需要创建图像对象; 你只想返回原始数据。
浏览器会将原始数据读入图像。

 return File(byteArray, "image/png"); 

显然,您需要传递正确的内容类型,具体取决于字节数组中的图像格式。