title: xmlhttprequest cannot load no 'access-control-allow-origin' only with post method (Angularjs)
body: <p>hi i am using angularjs and .net web api for my project. when i get data by GET method it work properly. But when i save data (POST) it give me error.</p>
  
  <p>1.Code to get data in  (It Work Fine)</p>
  
  <pre><code>A) angular service
  
  return $http.get(API_URL + '/Accounting/GetFeeGroup');
  
  B) Web API
  
  [HttpGet]
      public List&lt;FeeGroup&gt; GetFeeGroup()
      {
          return _feeGroupRepository.GetFeeGroup();
      }
  </code></pre>
  
  <p>2.Code To Save Data (It Give Error)</p>
  
  <pre><code>A) angular service
  var data = { 'FeeGroupID': "" + scope.FeeGroupID + "", 'FeeGroupName': "" + scope.FeeGroupName + "" }
      $http({
          url: API_URL + '/Accounting/SaveFeeGroup',
          method: "post",
          data: data,
          headers: { 'Content-Type': 'application/json' },
      })
      .success(function (data) {
          showSuccessMessage("Data Save Successfully");
          scope.GetFeeGroup();
      })
  
   B) Web API
  [HttpPost]
      public long SaveFeeGroup(FeeGroup feeGroup)
      {
          return _feeGroupRepository.Save(feeGroup);
      }
  </code></pre>
  
  <p>This give error like this</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load
    <a href="http://localhost:8081/api/Accounting/SaveFeeGroup" rel="nofollow noreferrer">http://localhost:8081/api/Accounting/SaveFeeGroup</a>. Response to
    preflight request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://localhost:8082" rel="nofollow noreferrer">http://localhost:8082</a>' is therefore not allowed
    access. The response had HTTP status code 404.</p>
  </blockquote>
  
  <p>i already do CORS origin thing</p>
  
  <pre><code>var cors = new EnableCorsAttribute("*", "*", "*");
          config.EnableCors(cors);
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{action}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );     
  </code></pre>
  
  <p>Please Help me it's so complicated for me that why it give error only with POST method.</p>