I have a sample that I am building using the Northwind database. I have a view in which I show all products for the specificc category and use ul to create elements with the image and the name and price of the product.
I used the code here http://blogs.msdn.com/b/miah/archive/2008/11/13/extending-mvc-returning-an-image-from-a-controller-action.aspx .
And came to the conclusion that if I right-click the image on my page, I will get follow the URL of the image.
This is the action method I provided that just accepts the category identifier. / Photo / show / 1
My action method in my ImageController is as follows:
// // GET: /Image/Show public ActionResult Show(int id) { var category = northwind.AllCategories().Single(c => c.CategoryID == id); byte[] imageByte = category.Picture; string contentType = "image/jpeg"; return this.Image(imageByte, contentType); }
Note. Image is a byte []
Then I will call it in my opinion as follows. (product is a model for my presentation)
But I still cannot get the image to be displayed.
source share