Not sure if I am doing this correctly but my image is not displaying anything as I understood it data:image/jpeg;base64 should convert the image, this part confuses me aswell "\"" at the end of the image src, the content of the image src is huge and looks like base64 but is not rendering as an image?
Details View:
<img class="img-responsive" src="@Html.Raw("data:image/jpeg;base64," + ViewBag.ImageToShow + "\"")" alt="">
The output I get is:
Controller:
// GET: /Post/Details/5
//[Authorize]
public ActionResult Details(string urlslug)
{
Post post = db.Posts.First(m => m.UrlSlug == urlslug);
byte[] buffer = post.Picture;
ViewBag.ImageToShow = Convert.ToBase64String(buffer);
if (post == null)
{
return HttpNotFound();
}
return View(post);
}
Aucun commentaire:
Enregistrer un commentaire