title: Post method not working with WebAPI 2 and Angular 4
body: <p>I am trying to learn Angular4 and implementing post method developed in ASP WebAPI and fetching into Angular4 application.</p>
  
  <pre><code>[Route("api/[controller]")]
  [EnableCors(origins: "*", headers: "*", methods: "*")]
  public class APIController : ApiController
  {
      [HttpPost]
      [Route("api/savePerson")]
      public IHttpActionResult savePerson(PersonModel model)
      {
          try
          {
              if (model.name != string.Empty || model.weight != 0 || model.height != 0 || model.proffession != 0)
              {
                  Guid guid = Guid.NewGuid();
                  Random random = new Random();
                  int i = random.Next();
                  model.id = i;
                  return Ok(model);
              }
              else
              {
                  return BadRequest();
              }
          }
          catch (Exception ex)
          {
              return InternalServerError("Something Went Wrong : " + ex.ToString());
          }
      }
  }
  </code></pre>
  
  <p>I have added System.Web.Cors from nuget package. 
  In my Angular class I am trying to post the values like this:
  <strong>Services.ts</strong>  </p>
  
  <pre><code>addPerson(person : Person){
      let headers = new Headers({ 'Content-Type': 'application/json' });
      let options = new RequestOptions({ headers: headers });
      return this.http.post(this.Base_URL + 'savePerson', person, options)
        .map(res=&gt;&lt;Person&gt;res.json()).catch(this.handleError);
    }
  </code></pre>
  
  <p>When I try to test the API from Postman, its working fine. But, when I try to call it from my Angular application I am getting error like this:</p>
  
  <blockquote>
    <p>OPTIONS <a href="http://sampleapi.ubiquitousdevelopers.com/api/savePerson" rel="nofollow noreferrer">http://sampleapi.ubiquitousdevelopers.com/api/savePerson</a> 405
    (Method Not Allowed) Failed to load
    <a href="http://sampleapi.ubiquitousdevelopers.com/api/savePerson" rel="nofollow noreferrer">http://sampleapi.ubiquitousdevelopers.com/api/savePerson</a>: Response for
    preflight has invalid HTTP status code 405</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/4YE2M.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4YE2M.jpg" alt="enter image description here"></a></p>
  
  <p>Its just a sample API so I didn't hide my Base URL. Anyone can test this API.
  My Get methods are working fine on this URL:
  <a href="http://sampleapi.ubiquitousdevelopers.com/api/getAllperson" rel="nofollow noreferrer">http://sampleapi.ubiquitousdevelopers.com/api/getAllperson</a></p>
  
  <p>POSTMAN Working Screenshot:
  <a href="https://i.stack.imgur.com/faogf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/faogf.jpg" alt="enter image description here"></a></p>
  
  <p><strong>My Web.Config file</strong></p>
  
  <p></p>
  
  <pre><code>  &lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt;
    &lt;remove name="OPTIONSVerbHandler" /&gt;
    &lt;remove name="TRACEVerbHandler" /&gt;
    &lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /&gt;
  &lt;/handlers&gt;
  </code></pre>