Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i want to create an image handler that will resize and serve images to my application, how do i call the handler on mvc?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
572 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...