在我的控制器中,我检索产品列表以及图像名称,然后将图像缩小到视图所需的大小。图像现在在内存中,可以写入响应流。我知道客户端会为每个图像发送响应,但我不知道如何连接到它以提供图像。
查看代码:
@foreach (var product in Model.Products)
{
@product.Name
<img src="@product.Thumbnail"/>
Priced From $@product.LowestPrice
}
控制器:
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))
}
);
ImageResizer.Resize() 签名在哪里
Resize(string imageName, int width, int height, Stream outputStream)
所以我认为我的问题应该是——我应该为图像名称输入什么以及如何监听可以写入流的每个图像的请求?