I have a sample I'm building, that's using the Northwind database. I have a view in which I show all the products for a specifc category and use a ul to generate items with an image and the products name and price.
I have 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 have gotten to the point that if I right-click an image on my page I get the follow for the image url.
This is the action method I provided, which just takes the Categores ID. /image/show/1
My action method in my ImageControll 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: Picture is a byte[]
I then call it in my view like this. (product is the Model for my view)
<%= Url.Action( "show", "image", new { id = product.Category.CategoryID } ) %>
But I still can't get the image to be displayed.