title: Can't access C# Controller from Typescript with Visual Studio Code
body: <p>I've been working for quite a few months on an Angular 4+ (we're at 6 now) with an ASP.NET Core backend using Visual Studio 2017, but I just couldn't take the amount of errors the VS2017 template would spill out any more. All and all, I always could debug just fine, but that template just won't allow for easy deployment.</p>
  
  <p>Fed up with all of it, I decided to give VS Code a spin, and I was amazed how Angular development works on it. I managed to migrate all my Typescript files to a new project (using <code>ng new my-project</code>), and I managed to browse and even publish with no hiccups, but no back-end either. And this is when things got rough. I created another project in VS Code, for the API using <code>dotnet new -o webapi</code>, and even though I could migrate all C# code to it and build it successfully, for the life of me I can't call my C# routes from typescript.</p>
  
  <p>For starters, I know that <code>ng serve</code> will deploy the angular aplication to port 4200 whereas <code>dotnet run</code> deploys the back-end to port 5000, which is a problem in itself, but how do I structure my code in order to run both applications <em>under the same port</em>? I don't want to go back to the SPA template (<code>dotnet new Angular</code>), which is the only kind of information I'm able to find regarding Angular6 + ASP.NET Core on both VS2017 and VS Code on Google. I followed <a href="https://www.c-sharpcorner.com/article/how-to-setup-angular-development-environment-in-visual-studio-code/" rel="nofollow noreferrer">this tutorial</a> to set my Angular 6 app in VS Code and it worked marvellously, but I can seem to find a way to create an C# API that it can listen to.</p>
  
  <p>Back in VS2017, I would just have both projects under the same solution, run the web project and everything worked hunky-dory. But now I have no idea how to structure my code in order to do the same under VS Code, I always get a 404 error whenever I try to call an method from the API (which is understandable, since I'm not listening to calls to the back-end at the same port I'm running the front-end application). In summary, I want to migrate the dev environment from VS2017 to VS Code without resorting to the SPA template while I run both front and back-end under the same port (like the template allows me to), but I'm stuck.</p>
  
  <p>Typescript call:</p>
  
  <pre><code>this.http.post('/api/lists/GetPack/', { Id: frameList.Id }).subscribe(result =&gt; {
    this.pack = result.json();
  });
  </code></pre>
  
  <p>C# controller:</p>
  
  <pre><code>[Route("api/[controller]")]
  public class ListsController : Controller
  {
      private ListDbContext context;
  
      public ListsController(ListDbContext context)
      {
          this.context = context;
      }
  
      [HttpPost]
      [Route("[action]")]
      public IActionResult GetPack([FromBody]HttpData postData)
      {
          var autoList = new AutoList(context);
          autoList.Load(postData.Id);
          var response = JsonConvert.SerializeObject(autoList.Pack);
          return Ok(response);
      }
  }
  </code></pre>