Hello Everyone,
I have a Asp.Net 5 Project with a Web Api Controller.
I would like to return an Image which I can than consume anywhere.
The Image does not display in the Browser, instead a json file shows up.
[HttpGet]
[Route("~/api/getimage/{imageid}")]
publicasyncTask<HttpResponseMessage> GetImage(string imageid)
{
var imageidint = Convert.ToInt32(imageid);
var firstOrDefault = _applicationDbContext.Images.FirstOrDefault(n => n.Id == imageidint);
var stream = default(MemoryStream);
stream = firstOrDefault == null ? newMemoryStream(_applicationDbContext.Images.FirstOrDefault(n => n.Id == 6).Data) : newMemoryStream(firstOrDefault.Data);
var response = newHttpResponseMessage { Content = newStreamContent(stream) };
response.Content.Headers.ContentType = newMediaTypeHeaderValue("image/png");
return response;
}
This Code used to work in previous Versions, but now I only get:
{"Version":{"Major":1,"Minor":1,"Build":-1,"Revision":-1,"MajorRevision":-1,"MinorRevision":-1},"Content":{"Headers":[{"Key":"Content-Type","Value":["image/png"]}]},"StatusCode":200,"ReasonPhrase":"OK","Headers":[],"RequestMessage":null,"IsSuccessStatusCode":true}
Is there a default Json Formatter, which I can override?
I would appreciate and help greatly, Thank You Kind blessings