I am trying to write an endpoint in ASP.net core to respond to img
src tags to display the image without fetching the image data manually. I save the uploaded images as is. Now I want to create an endpoint in ASP.net core to act as if src link is a file.
I put this into my src
attribe:
http://localhost:4000/api/ecm/GetImage?imageID=a7a0cc09-474e-4e7e-9dd0-d23c867f9e4a
And this is the code of the GetImage
:
[HttpGet]
[IgnoreAntiforgeryToken]
[Produces("image/jpg", "image/png", "image/webp")]
public Binary GetImage([FromQuery] string imageID)
{
return (service.GetImage(imageID));
}
But the request gives me 406 error (Not Acceptable).
What is the correct way to do this?