Is there a performance difference between returning image in Controller or View?

0

I just learned how to fetch and display an image from the database. I was able to do this in two ways:

First: Through an ActionResult in my Controller:

    public ActionResult RetornaImagemDoBanco(int id)
    {
        byte[] imageData = db.Tab_Documentos_Parente.Find(id).Documento;
        return new FileStreamResult(new System.IO.MemoryStream(imageData), "image/jpeg");
    }

And in my View it looks like this:

@{ string imagem = @"/Documentos_Parente/RetornaImagemDoBanco/" + Model.Id;}
<image src=@imagem alt="" />

Second: Directly in View:

@if (Model.Documento != null)
{
   var base64 = Convert.ToBase64String(Model.Documento);
   var imgSrc = String.Format("data:image/gif;base64,{0}", base64);
   <img src = @imgSrc alt = "" />
}
else
{
   <img src = "#" alt = "" />
}

My question is: Is there any significant performance difference between these methods? Well, I'm going to return a list of student records with their respective photos and there may be hundreds of records . Suggest a different way?

    
asked by anonymous 22.08.2017 / 19:35

0 answers