title: Angular Http Post to .Net Core
body: <p>Trying to make to Post to a .net core from Angular. The get operation can be done smoothly, but the post operation can not be performed.
  It is seen when debug is done that the Api method is never called.
  Responce Response {_body: "", status: 200, ok: true, statusText: "OK", headers: Headers,}</p>
  
  <p>Controller:</p>
  
  <pre><code>[Produces("application/json")]
  [Route("api/[controller]")]
  public class StokKartsController : Controller
  {
      private readonly StokKartContext _context;
  
      public StokKartsController(StokKartContext context)
      {
          _context = context;
      }
      [HttpGet("[action]")]
      public IEnumerable&lt;StokKart&gt; deneme()
      {
          return _context.stok.ToList();
      }
      [HttpPost]
      public IActionResult StokKartEkle([FromBody] StokKart stokKart)
      {
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
          _context.stok.Add(stokKart);
          _context.SaveChanges();
          return Json(stokKart);
      }
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>public class StokKart
  {
      [Key]
      public string urunKodu { get; set; }
      public string urunAdi { get; set; }
      public string urunGrubu { get; set; }
      public string ureticiKodu { get; set; }
      public int barkodKodu { get; set; }
      public string uretici { get; set; }
      public string urunTipi { get; set; }
      public string marka { get; set; }
      public string model { get; set; }
      public string birim { get; set; }
      public int kdv { get; set; }
      public float alisFiyati { get; set; }
      public float satisFiyati { get; set; }
      //public bool? serinoTakibiYap { get; set; }
  }
  </code></pre>
  
  <p>TypeScript:</p>
  
  <pre><code> import { Component, Inject, OnInit } from '@angular/core';
   import { Http, Headers, RequestOptions } from '@angular/http';
   import 'rxjs/add/operator/map';
  
   @Component ({
       selector: 'stokKarti',
       templateUrl: './stokKarti.component.html',
       styleUrls: ['./stokKarti.component.css']
   })
   export class StokKartiComponent implements OnInit {
  
        stokKarts: IStokKart[];
        stokKart: IStokKart;
        headers: Headers;
        http: Http;
        options: RequestOptions;
        baseUrl: string;
  
        constructor(http: Http, @Inject('BASE_URL') baseUrl: string) {
            this.http = http;
            this.baseUrl = baseUrl;
            let headers = new Headers({ 'Content-Type': 'application/json' });
            let options = new RequestOptions({ headers: headers });
  
       }
       ngOnInit() {
          this.http.get(this.baseUrl + 'api/StokKarts/deneme').subscribe(result =&gt; {
              this.stokKarts = result.json() as IStokKart[];
              console.log(result);
          }, error =&gt; console.error(error));       
       }
  
       public urunKayit(e: any) {      
           //e.preventDefault();
           //this.stokKart.urunKodu = e.path[12].getElementById("urunKodu").value;
           //this.stokKart.urunTipi = e.path[12].getElementById("urunTipi").value;
  
           let stoks: IStokKart = &lt;IStokKart&gt;{
              "urunKodu": "U01",
              "urunAdi": " ",
              "urunGrubu": " ",
              "ureticiKodu": " ",
              "barkodKodu": 1,
              "uretici": " ",
              "urunTipi": " ",
              "marka": " ",
              "model": " ",
              "birim": " ",
              "kdv": 1,
              "alisFiyati": 2.5,
              "satisFiyati": 3.5
          };
          this.http.post(this.baseUrl + 'api/StokKarts/StokKartEkle', JSON.stringify(stoks), this.options)
          .subscribe(res =&gt; console.log(res), error =&gt; console.error(error));
       }
     }
  
     interface IStokKart {
           urunKodu: string;
           urunAdi: string;
           urunGrubu: string;
           ureticiKodu: string;
           barkodKodu: number;
           uretici: string
           urunTipi: string;
           marka: string;
           model: string;
           birim: string;
           kdv: number;
           alisFiyati: number;
           satisFiyati: number;
      }
  </code></pre>