image handler on mvc

后端 未结 1 1401
闹比i
闹比i 2020-12-16 08:22

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

相关标签:
1条回答
  • 2020-12-16 08:45

    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 讨论(0)
提交回复
热议问题