title: “Http failure response for (unknown url): 0 Unknown Error” instead of actual error message in Angular
body: <p> 
  I'm totally new to Angular 6 &amp; .NET web api. I'm trying to call post api from my angular app using <code>HttpClient</code>. but I'm getting CORS error:</p>
  
  <blockquote>
    <p>OPTIONS <a href="http://localhost:64458/api/employee/insert" rel="nofollow noreferrer">http://localhost:64458/api/employee/insert</a> 404 (Not Found)</p>
    
    <p>Access to XMLHttpRequest at '<a href="http://localhost:64458/api/employee/insert" rel="nofollow noreferrer">http://localhost:64458/api/employee/insert</a>' from origin '<a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.</p>
    
    <p>core.js:15724 ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "<a href="http://localhost:64458/api/employee/insert" rel="nofollow noreferrer">http://localhost:64458/api/employee/insert</a>", ok: false, …}</p>
  </blockquote>
  
  <p>Here is my angular service.ts code:</p>
  
  <pre class="lang-c# prettyprint-override"><code>url = 'http://localhost:64458/api/employee';
  constructor(private http:HttpClient) {}
  httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json'}) };  
  
  insert(obj: any): Observable&lt;any&gt;{
      return this.http.post&lt;any&gt;(this.url + '/insert', obj,this.httpOptions).pipe(map(res =&gt; res));
  }
  </code></pre>
  
  <p>Here is my web api code:</p>
  
  <pre class="lang-c# prettyprint-override"><code>[RoutePrefix("api/employee")]
  public class HomeController : ApiController
  {
      [HttpPost]
      [Route("insert")]
      public IHttpActionResult PostEmployee(dynamic data)
      {
          try
          {
              return Ok();
          }
          catch (Exception)
          {
              throw;
          }
      }
  }
  </code></pre>
  
  <p>What can be the issue?</p>