In this article i will show you, How to display image from database in ASP.NET MVC. To do this task, we will use <img /> tag in view section. First of all, Create a connection with the database using Entity Data model (Learn How to use ADO.NET Entity Data Model). In the controller action method pass the list of data to the view. Like that:
private DatabaseEntities db = new DatabaseEntities();
// GET: Home
public ActionResult Index()
{
return View(db.Employees.ToList());
}
In the View section:
@model IEnumerable<WebApplication23.Employee>
@foreach (Employee item in Model)
{
<img src="@Url.Content(item.Database_Picture_column)" width="100" height="100" />
}