Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request against localhost relative url "Cannot assign requested address"

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.

like image 711
myusrn Avatar asked Dec 28 '18 05:12

myusrn


1 Answers

I am using the same ASP.NET Core docker version and it seems work as described below:

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

Try again and check if it works for you!

like image 145
FabioGM Avatar answered Oct 13 '22 08:10

FabioGM