Web API localhost not getting resolved from c# code
<p>Same question as: <a href="https://stackoverflow.com/questions/33671989/localhost-not-getting-resolved-from-c-sharp-code#_=_">https://stackoverflow.com/questions/33671989/localhost-not-getting-resolved-from-c-sharp-code#<em>=</em></a></p>

<p>Resource: <a href="http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client" rel="nofollow noreferrer">http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client</a></p>

<p>Code Snippet:</p>

<pre><code>static async Task RunAsync()
{
    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("http://localhost:9000/");
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

        // HTTP GET
        HttpResponseMessage response = await client.GetAsync("api/products/1"); //Fails Here
        if (response.IsSuccessStatusCode)
        {
            Product product = await response.Content.ReadAsAsync&lt;Product&gt;();
            Console.WriteLine("{0}\t${1}\t{2}", product.Name, product.Price, product.Category);
        }          
    }
}
</code></pre>

<p>Do not understand answer given in the pre-mentioned question above:</p>

<p>The most likely explanation is that the code in question is blocked by a firewall and thus the connection is refused because the application doesn't have permission to reach the target. -- I opened my Firewall (Home computer) and saw my application in the list so I ticked the checkbox next to it, tried also combinations of Private or Public (have no idea what this is) however made no difference.</p>

<p>The next most likely explanation is that the target is listening only on IPv6 (not IPv4) and thus the connection fails when the DNS resolution returns the IPv4 address rather than the IPv6 address. -- ???</p>

<p>Error I get is:</p>

<pre><code>An error occurred while sending the request.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:9000
</code></pre>