开发者

image handler on mvc

开发者 https://www.devze.com 2023-01-22 06:35 出处:网络
i want to create an image handler that will resize and serve images to my application, how do开发者_高级运维 i call the handler on mvc?You would use return a FileStreamResult in your action method ins

i want to create an image handler that will resize and serve images to my application, how do开发者_高级运维 i call the handler on mvc?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消