title: MVC project uses Web API project inside same Docker container
body: <p>I am trying to learn more about Docker in my free time. I am currently trying to get ASP.NET Identity Server to work with it.  </p>
  
  <p>Here are the steps I have taken:</p>
  
  <ol>
  <li><p>Download: <a href="https://github.com/IdentityServer/IdentityServer4.Samples/tree/release/Quickstarts/6_AspNetIdentity" rel="nofollow noreferrer">https://github.com/IdentityServer/IdentityServer4.Samples/tree/release/Quickstarts/6_AspNetIdentity</a></p></li>
  <li><p>Run the ASP.NET MVC client application and the server application and browse to the following URL to make sure it is working properly: <a href="http://localhost:5002/Home/CallApiUsingClientCredentials" rel="nofollow noreferrer">http://localhost:5002/Home/CallApiUsingClientCredentials</a></p>
  
  <p>The code looks like this:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; CallApiUsingClientCredentials()
  {
          var tokenClient = new TokenClient("http://localhost:5000/connect/token", "mvc", "secret");
          var tokenResponse = await tokenClient.RequestClientCredentialsAsync("api1");
  
          var client = new HttpClient();
          client.SetBearerToken(tokenResponse.AccessToken);
          var content = await client.GetStringAsync("http://localhost:5001/identity");
  
          ViewBag.Json = JArray.Parse(content).ToString();
          return View("Json");
  }
  </code></pre>
  
  <p>I get the response I am expecting.</p></li>
  <li><p>Right click on the API project and select Add Container Orchestration Support.</p></li>
  <li>Right click on MVCClient and select: Add/Container Orchestration Support.  </li>
  </ol>
  
  <p>Docker Compose Override then looks like this:</p>
  
  <pre><code>version: '3.4'
  
  services:
    mvcclient:
      environment:
        - ASPNETCORE_ENVIRONMENT=Development
      ports:
        - "5002:80"
  
    api:
      environment:
        - ASPNETCORE_ENVIRONMENT=Development
      ports:
        - "5001:80"
  
  
    identityserverwithaspnetidentity:
      environment:
        - ASPNETCORE_ENVIRONMENT=Development
      ports:
        - "5000:80"
  </code></pre>
  
  <p>Make changes to the code above as follows:</p>
  
  <p>Line 3 change to:</p>
  
  <pre><code>var tokenClient = new TokenClient("http://identityserverwithaspnetidentity:80/connect/token", "mvc", "secret");
  </code></pre>
  
  <p>Line 10 change to:</p>
  
  <pre><code>var content = await client.GetStringAsync("http://api:80/Identity");
  </code></pre>
  
  <p>When I browse to <a href="http://localhost:5002/Home/CallApiUsingClientCredentials" rel="nofollow noreferrer">http://localhost:5002/Home/CallApiUsingClientCredentials</a>; I am receiving a weird response:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"&gt;&lt;html&gt;&lt;head&gt;&lt;meta http-equiv=\"refresh\" content=\"0;url=http://www.webaddresshelp.bt.com/main?ParticipantID=mg76cjr54t8kx45jjw4j4k9j5hsr5m26&amp;FailedURI=http%3A%2F%2Fapi1%2FIdentity&amp;FailureMode=1&amp;Implementation=&amp;AddInType=4&amp;Version=pywr1.0&amp;ClientLocation=uk\"/&gt;&lt;script type=\"text/javascript\"&gt;url=\"http://www.webaddresshelp.bt.com/main?ParticipantID=mg76cjr54t8kx45jjw4j4k9j5hsr5m26&amp;FailedURI=http%3A%2F%2Fapi1%2FIdentity&amp;FailureMode=1&amp;Implementation=&amp;AddInType=4&amp;Version=pywr1.0&amp;ClientLocation=uk\";if(top.location!=location){var w=window,d=document,e=d.documentElement,b=d.body,x=w.innerWidth||e.clientWidth||b.clientWidth,y=w.innerHeight||e.clientHeight||b.clientHeight;url+=\"&amp;w=\"+x+\"&amp;h=\"+y;}window.location.replace(url);&lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>What is the problem please?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Why do the lines below return the output above (what I referred to as the weird response):</p>
  
  <pre><code>var content = await client.GetStringAsync("http://bert:80/Identity");
  var content = await client.GetStringAsync("http://somerandomserver:80/Identity");
  var content = await client.GetStringAsync("http://hello:80/Identity");
  </code></pre>
  
  <p>bert; somerandomserver and hello do not exist.  It appears the response above is always received as long as I use port 80 i.e. regardless of the server name I use i.e. I can make it up.  Why?</p>