I'm loading an image from database and showing this image in the _Layout.cshtml.
The image can change (after log in) and each company may have a different image, so after the log in, I go to the database and get the corresponded image for that company (based on it's Id). I need to keep this loaded image and is not needful to go to the server again.
Everything work fine, I can load the image and show in the _Layout, but after every request, the Image "blinks" because the _Layout is being recreated.
I've followed this question (step 1) to load the image from database.
The code that I have is:
public ActionResult CarregarLogoEmpresa()
{
if (SecurityManager.Instance.Identity.IsAuthenticated)
{
var codigoEmpresaLogada = SecurityManager.Instance.Session.IdEmpresa;
var logoEmpresa = _empresaAppService.BuscarLogoEmpresa(codigoEmpresaLogada);
//return Json(Convert.ToBase64String(logoEmpresa), JsonRequestBehavior.AllowGet);
return File(logoEmpresa, "image/jpg");
}
return null;
}
And in the View:
<img src='@Url.Action("CarregarLogoEmpresa", "Image")' />
Is there a way keep the Image loaded instead of being recreated, avoiding the blinking everytime?