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

Categories

0 votes
562 views
in Technique[技术] by (71.8m points)

asp.net mvc - image handler on mvc

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

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

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...