[英]Resizing Images through controller
Due to some reasons I have to get images through a controller , ImageController:ViewFile(int id)
. 由于某些原因,我必须通过控制器
ImageController:ViewFile(int id)
来获取图像。
But then I cant use image resizing . 但后来我不能使用图像调整大小 。
I have tried: 我努力了:
<img src="/File/ViewImage/4?width=100"/><br/>
ok for those Controller is as follows: 这些控制器的确定如下:
public class FileController : Controller
{
private readonly IFileService _fileService;
public FileController(IFileService fileService)
{
_fileService = fileService;
}
public ActionResult ViewImage(int id)
{
var image = _fileService.ViewImage(id);
if (image == null)
{
return new HttpNotFoundResult();
}
return File(image.FilePath, image.ContentType, image.FileName);
}
........
But no luck. 但是没有运气。 has anyone has same problem ?
有谁有同样的问题?
The ImageResizer Best Practices explain why you should use the URL API directly instead of writing your own handler. ImageResizer最佳实践说明了为什么应该直接使用URL API而不是编写自己的处理程序。 If you need to add authentication rules or a custom data source, ImageResizer offers custom events and a plugin API for that.
如果您需要添加身份验证规则或自定义数据源,ImageResizer将提供自定义事件和一个插件API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.