I'm new to Asp.NET MVC development and a I want to make an application that displays multiple images from a database in the same View. I'm storing the images as LONGBLOB and converting then to a base 64 string.
I'm trying to display them like this:
<img src=<%:Html.Value("photo")%> />
However, I think that the URL doesn't support too big strings as parameters.
My Question is: Which is the best way to display images from database? I need to store them in a image server? Create a maps route to save the images in each URL?
I hope it was clear.
You could try something like this:
FileContentResult
public ActionResult MYsample()
{
var MyList = storeDB.GenreList();
var a= MyList.Count;
if (a != null)
{
foreach (var li in MyList)
{
return File(li.fileContent, li.mimeType,li.fileName);
}
}
return View(MyList);
}
View
@foreach (var item in Model)
{
<img src="@Url.Action("MYsample", "HomeController", new { id = item.ProductID })" alt="@item.Productname" />
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.