I can not return the images from a controller. Below I explain all the encoding:
I created a controller, and a view for this controller that returns the image that is in an Oracle blob field. It worked, usually with the controller and view below:
public class ImagemController : Controller
{
// GET: Imagem
public ActionResult Index()
{
return View();
}
public ActionResult GetImagem(int id)
{
Entities1 tabela = new Entities1();
byte[] BlobImg = tabela.DATABINARY.Where(p => p.ID.Equals(843)).Select(p => p.DATA).FirstOrDefault();
return File(BlobImg, "image/png");
}
}
}
View:
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Teste de Imagem</h2>
<img src="@Url.Action("GetImagem")" width="100"/>
Now, I created a new controller, to look for inventory information and in this controller I have the IDBLOB attribute, as follows:
public class ProntaEntregaController : Controller
{
// GET: ProntaEntrega
public ActionResult Index()
{
Entities1 Estoque = new Entities1();
List<V500_ESTOQUE_PE_WEB> ProntaE = (from p in Estoque.V500_ESTOQUE_PE_WEB select p).Where(x => x.IDBLOB != null).ToList();
return View(ProntaE);
}
}
}
And I did the view, as below for test purposes only, but the images are not returned. It's just an image icon, as if it did not load (I'll only put one part to not get too long):
<tr>
<td>
@Html.DisplayFor(d => item.COD_REDUZIDO)
</td>
<td>
@Html.DisplayFor(d => item.TOTAL_KG_PE)
</td>
<td>
<img src="@Url.Action("GetImage", new { id = item.IDBLOB })" width=100 />
</td>
</tr>