Cleiton Limas

Cleiton Limas

  • NA
  • 7
  • 492

Return a blob image error

Jan 4 2018 8:04 PM
Hello guys,
I created a controller and a view, to fetch data from my database an image, which is in blob format. However, the image is not loaded in the view (I call a method to call this view).
I have the controller Image (with the GetImage method), the ReadyDrive controller and the ReadyDelivery view. Within the ReadyDate view, I pass the parameter to get the ID in the GetImage method.
Controller Imagem:
  1. public ActionResult Index()  
  2. {  
  3.     return View();  
  4. }  
  5. public ActionResult GetImagem(int id)  
  6. {  
  7.     Entities1 tabela = new Entities1();  
  8.   
  9.     byte[] BlobImg = tabela.DATABINARY.Where(p => p.ID.Equals(id)).Select(p => p.DATA).FirstOrDefault();  
  10.     return File(BlobImg, "image/png");  
  11. }  
Controller ProntaEntrega
 
  1. public ActionResult Index(int? reduzido=null)  
  2.   {  
  3.       Entities1 Estoque = new Entities1();  
  4.       List<V500_ESTOQUE_PE_WEB> ProntaE = (from a in Estoque.V500_ESTOQUE_PE_WEB select a).OrderByDescending(x => x.TOTAL_KG_PE).ToList()  
  5.                                          .Where(x => reduzido != null ? x.COD_REDUZIDO.Equals(reduzido) : true).ToList();  
  6.   
  7.   
  8.       return View(ProntaE);  
  9.   }  
View ProntaEntrega (a piece of that):
 
  1. <tbody>  
  2.     @foreach (var item in Model)  
  3.     {  
  4.   
  5.         <tr>  
  6.             <td class="text-left" width="30%">  
  7.                 @Html.DisplayFor(d => item.COD_REDUZIDO)  
  8.             </td>  
  9.             <td class="text-left">  
  10.                 @Html.DisplayFor(d => item.DESC_ARTIGO)  
  11.             </td>  
  12.             <td class="text-right">  
  13.                 @Html.DisplayFor(d => item.TOTAL_KG_PE)  
  14.             </td>  
  15.             <td>  
  16.                 <img src="@Url.Action("GetImage", "Imagem", new { id = @item.IDBLOB})" width=50 />  
  17.             </td>  
  18.         </tr>  
  19.   
  20.     }  
  21. </tbody>  
 But the images do not load on view.
 
Any help me?
 
Thanks! 
 
 
 

Answers (2)