Return jpeg image from Asp.Net Core WebAPI

前端 未结 4 843
青春惊慌失措
青春惊慌失措 2020-12-08 09:30

Using asp.net core web api, I want to have my controller action method to return an jpeg image stream.
In my current implementation, b

4条回答
  •  心在旅途
    2020-12-08 09:54

    [HttpGet("Image/{id}")]
        public IActionResult Image(int id)
        {
            if(id == null){ return NotFound(); }
            else{
    
                byte[] imagen = "@C:\\test\random_image.jpeg";
                return File(imagen, "image/jpeg");
            }
        }
    

提交回复
热议问题