In my controller I retrieve a list of products along with an image name, then scale the image down to the size needed by the view. The images are now in memory, ready to be written to the response stream. I know the client will send a response for each image but I have no idea how to hook into it to provide the image.
View code:
@foreach (var product in Model.Products)
{
@product.Name
<img src="@product.Thumbnail"/>
Priced From $@product.LowestPrice
}
Controller:
model.Products =
DataContext.Products.Where(p => p.Category.Name
.Equals(id)).Select(m => new ProductListItem
{
Name = m.Name,
Thumbnail = ImageResizer.Resize(m.Image, 75, 100, <normally I put the output stream here>),
LowestPrice = SqlFunctions.StringConvert( m.PriceSet.Prices.Min(p =>p.Price1))
}
);
Where ImageResizer.Resize() signature is
Resize(string imageName, int width, int height, Stream outputStream)
So my question I think should be- what do I put in for the image name and how do I listen for requests for each image that can be written to the stream?