I stored few images in sql server database in binary format and then retrieved them back and im able display as image but my requirement is that i should display all the images as gallery from database but im able to display only the 1st image as gallery...
my problem is in my controller code as in the forloop its returning file for the first loop itself and view is displayed
Controller
public ActionResult DislpayAllImage()
{
DataSet dsa = new DataSet();
dsa = objImage.getAllImages();
DataTable dt = new DataTable();
dt = dsa.Tables[0];
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Byte[] image = (Byte[])dt.Rows[i]["UsImage"];
return File(image, "image/jpg");
}
}
return View();
}
View
@foreach( var image in ViewData.Images )
{
<img src="@Url.Action("DislpayAllImage", "Home",new { id = image.ImageID })" />
}