Question: I have a visual studio 2017 [ / 2019 ] asp.net core web app project enabled with docker support using `FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base` and `FROM microsoft/dotnet:2.1-sdk AS build` images. 

When my f5 debug instance starts up on <http://localhost:44301/> I attempt to make HttpClient.SendAsync() request against relative url `/data/some.json` to pull in data making localhost debugging able to emulate security state only present in published app case. 

When I f5 debug using project's IISExpress target this all works fine. When I f5 debug against the Docker target the HttpClient.SendAsync() call against the localhost relative url, or fully qualified `https://localhost:44301/data/some.json` and `http://localhost:8081/data/some.json` paths, generates the exception with message `Cannot assign requested address`. If I change code to load some.json from a remote url, e.g. storage account public blob path, the f5 debug Docker target does not fail on this call.

One can repro issue using the `https://github.com/myusrn/adncauthexploration.git` provided `AzWebApp1` project which also requires `https://github.com/myusrn/KK.AspNetCore.EasyAuthAuthentication.git` that is accessed using a project reference, to enable debugging contents of this nuget package. Using localhost f5 iisexpress target the issue doesn't repro. Switching to localhost f5 docker target the issue repros when debug url processing hits `KK.AspNetCore.EasyAuthAuthentication\Services\EasyAuthWithAuthMeService.cs` | line 109 `var response = await client.SendAsync(httpRequest);`.

I'm wondering if there is some Dockerfile setting I need to be making to enable this f5 debug localhost relative url request by the asp.net core web app startup code.

Answer: 
I am using the same ASP.NET Core docker version and it seems work if you do this:

replace `http://localhost:<port>`

with

`http://host.docker.internal:<port>`

Try again and check if it works for you!
For accessing resource from `IIS Express`, `SelfHost` and `Docker`, you could configure `HttpClient.BaseAddress` with Http Request like below: 

```
public class HomeController : Controller
{
    private readonly HttpClient httpClient;
    public HomeController(
        , IHttpClientFactory httpClientFactory)
    {
        this.httpClient = httpClientFactory.CreateClient();
    }
    public async Task<IActionResult> Index()
    {
        this.httpClient.BaseAddress = new Uri($"{this.Request.Scheme}://{this.Request.Host}");
        var response = await httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get,
            "data/some.json"));
        var result = await response.Content.ReadAsStringAsync();

        return View();
    }
}

```