1
Answer

How to display photo in mvc

Shibly  Sadik

Shibly Sadik

9y
493
1
I have uploaded photos successfully in  "Content/Student/Photo" folder of my project  but can't display them in Index view.
 
here is my short code:
 
Model:
 
public string FirstName { get; set; }

[Display(Name = "Upload Image")]
[NotMapped]
public HttpPostedFileBase Photo { get; set; } 
 
Index View(for display):
@Html.DisplayNameFor(model => model.FirstName)
@Html.DisplayNameFor(model => model.Photo)

@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.FirstName)

@Html.DisplayFor(modelItem => item.Photo)
}
 
what changes should  be made in the Index view??
 
 
Answers (1)