Return jpeg image from Asp.Net Core WebAPI

前端 未结 4 845
青春惊慌失措
青春惊慌失措 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条回答
  •  旧时难觅i
    2020-12-08 10:15

    PhysicalFile helps to return file from Asp.Net Core WebAPI with a syntax simple

        [HttpGet]
        public IActionResult Get(int imageId)
        {            
           return PhysicalFile(@"C:\test.jpg", "image/jpeg");
        }
    

提交回复
热议问题