I am using ASP.NET MVC and I am trying to upload multiple images to a database and then display them in a view. I believe the upload process is working however when I try to display the images only the alternative text is being shown and a resource cannot be found error in the Chrome debugging.
This is how my image is displayed in my view
@model IList<InspectionPhoto>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Photo Management</h4>
</div>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="modal-body">
<div class="form-horizontal">
@if (Model.Count > 0)
{
<div class="row">
@for (var i = 0; i < Model.Count(); i++)
{
<div class="row">
<div class="col-md-6">
<img src="@Url.Action( "ShowPhoto", "Inspection", new { id = Model[i].PhotoID } )" alt="Image not available" />
</div>
//continues
Show Photo method:
public Bitmap ShowPhoto(int id)
{
InspectionPhoto image = db.InspectionPhotoes.Find(id);
var result = (Bitmap)((new ImageConverter()).ConvertFrom(image.ImageBytes));
return result;
}
The show photo method is in my Inspections controller because the Photo view is a modal partial view that is show when a button is clicked in the inspection view.
Any help would be greatly appreciated. Please let me know if more information is needed.
InspectionorInspections? 3) In your view you are expecting an URL but your action method returns a bitmap...