Display Image in asp.net core postgresql

 The below code works in Index Page 
                var base642 = Convert.ToBase64String(item.Imagesol);
                var Image2 = String.Format("data:image/gif;base64,{0}", base642);
            <img src="@Image2" alt="" class="img-fluid">

Can someone give me equivalent code for Details page, I like to display images in asp.net core postgresql

<dt class = "col-sm-2">
        @Html.DisplayNameFor(model => model.Imagesol)
    <dd class = "col-sm-10">
        @Html.DisplayFor(model => model.Imagesol)

Here is the definition in class file public byte[]? Imagesol { get; set; }

A set of technologies in the .NET Framework for building web applications and XML web services.
4,393 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 51,346 Reputation points

    The same code will work in any page. Assuming you're model has the image then take the code that is working on your index page and paste it into the details page.

    Note that the code you're showing on the details page is auto-generated but you don't have to use it. In this case since you just want to show it replace the contents of the <dt> with just the img tag that you're using on the index page. DisplayNameFor and DisplayFor don't make sense for an image. Since this structure is in a table you'll likely want the dt to be either blank or just something simple like Image and the dd to be the actual image.

    <dt class = "col-sm-2">
       <label for="Imagesol">Image</label>
    <dd class = "col-sm-10">
       <img src="@Image2" alt="" class="img-fluid">

1 additional answer

Sort by: Most helpful
  1. AgaveJoe 27,656 Reputation points

    Your post is very confusing. Why can't you simply repeat the same approach you are using in the first code block to embed the image in a img element?