i want to create an image handler that will resize and serve images to my application, how do i call the handler on mvc?
Asked
Active
Viewed 5,570 times
1 Answers
7
You would use return a FileStreamResult
in your action method instead of a handler.
public ActionResult GetFile()
{
using (FileStream stream = new FileStream())
{
FileStreamResult result = new FileStreamResult(stream, "image/jpg");
result.FileDownloadName = "image.jpg";
return result;
}
}
You could implement some resizing logic in the action.

Dustin Laine
- 37,935
- 10
- 86
- 125
-
1how i use it on the page
? – eyalb Oct 26 '10 at 21:13
-
1You reference it as a URL. `http://domain.com/Controller/GetFile` as in my example above. You could also return a `byte[]` if the file is dynamic. – Dustin Laine Oct 26 '10 at 21:15