My images are stored in the database in a byte array format, it displays everything perfectly through forich, but when I want to open a page to work with a certain image, it gives an error saying that I am passing a non-byte value, although when I step through the code and watch the transmitted value , it displays byte [values].
@foreach (var item in Model) { <tr> <td> @Html.Raw("<img style='width:80px; height:60px;' src=\"data:image/jpeg;base64," + Convert.ToBase64String(item.Image) + "\" />") </td> <td> @Html.ActionLink("Edit", "Edit", "Personal", new { id = item.Id, item.Image }, null) </td> <td> @Html.ActionLink("Remove", "Delete", "Personal", new { id = item.Id}, null) </td> </tr> } in Edit, I pass the image id and its byte array itself. Edit:
public ActionResult Edit(int id, byte[] image) { ApplicationUser au = db.Users.Find(User.Identity.GetUserId()); Picture pic = new Picture { Id = id, Image = image}; return View(pic); } Table structure
CREATE TABLE [dbo].[Pictures] ( [Id] INT IDENTITY (1, 1) NOT NULL, [Size] NVARCHAR (MAX) NULL, [Image] VARBINARY (MAX) NULL, [UserId] NVARCHAR (MAX) NULL, [ApplicationUser_Id] NVARCHAR (128) NULL, CONSTRAINT [PK_dbo.Pictures] PRIMARY KEY CLUSTERED ([Id] ASC), CONSTRAINT [FK_dbo.Pictures_dbo.AspNetUsers_ApplicationUser_Id] FOREIGN KEY ([ApplicationUser_Id]) REFERENCES [dbo].[AspNetUsers] ([Id]) ); It seems to me that it is possible to transfer an element of a collection somehow easier, but I cannot select one element on the controller in the controller.

public ActionResult Edit(int id, byte[] image) { ApplicationUser au = db.Users.Find(User.Identity.GetUserId()); Picture pic = new Picture(); foreach (var item in au.Pictures) { pic = from p in au.Pictures where p.Id == id select p; } //Picture pic = new Picture { Id = id, Image = image}; return View(pic); }public ActionResult Edit(int id, byte[] image) { ApplicationUser au = db.Users.Find(User.Identity.GetUserId()); Picture pic = new Picture(); foreach (var item in au.Pictures) { pic = from p in au.Pictures where p.Id == id select p; } //Picture pic = new Picture { Id = id, Image = image}; return View(pic); }public ActionResult Edit(int id, byte[] image) { ApplicationUser au = db.Users.Find(User.Identity.GetUserId()); Picture pic = new Picture(); foreach (var item in au.Pictures) { pic = from p in au.Pictures where p.Id == id select p; } //Picture pic = new Picture { Id = id, Image = image}; return View(pic); }- Artem Danchenko