I have a 4.7.2 application and I'm trying to rewrite it in .net core 3.1.
I have a method in a controller below. Of course, the real code is different I receive some parameters and generate a URL, etc. But the idea is the same. I am trying to reflect another server's response.
[Route("images")]
public async Task<HttpResponseMessage> GetImage()
{
Uri uri = new Uri("https://img-lcwaikiki.mncdn.com/mnresize/1024/-/pim/productimages/20202/4353414/l_20202-0w9011z8-hrz_a.jpg", UriKind.Absolute);
using (HttpClient client = new HttpClient())
{
return await client.GetAsync(uri);
}
}
But interestingly, .net framework and core act totally different.
Framework, returns the image as I expected (.net Framework 4.7.2 Sample).
But core returns a json in the body (.net Core 3.1 Sample).
I've checked the Microsoft Documentation, they are the same for Sytem.Net.Http.HttpClient class both in netCore 3.1 and .net Framework 4.7.2.
To reproduce you can create a fresh netCore and .netFramework apps. BTW I've created a repo for this projects: https://github.com/fkucuk/imagereflectorhttpclient