0

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 ?

DarthVader
  • 52,984
  • 76
  • 209
  • 300

1 Answers1

1

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.

Lilith River
  • 16,204
  • 2
  • 44
  • 76
  • I am not sure what you mean by URL API, i have to return images from a controller, cause they are not in the same folder with Application, they are in a shared folder, I have a web app, and a back end within domain. – DarthVader Oct 28 '13 at 20:17