Due to some reasons I have to get images through a controller , 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. If you need to add authentication rules or a custom data source, ImageResizer offers custom events and a plugin API for that.