title: Login to WinApi C# using Angular
body: <p>I get this error when I send Post. Do you know what I have to do? Login to WinApi C#</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://localhost:56305/Token" rel="nofollow noreferrer">http://localhost:56305/Token</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:64757" rel="nofollow noreferrer">http://localhost:64757</a>' is therefore not allowed
    access. The response had HTTP status code 400.</p>
  </blockquote>
  
  <p>My code </p>
  
  <pre><code>//linki
      $scope.addLink = "http://localhost:56305/Token";
  
      $scope.addData = function () {
          if ($scope.password != "" &amp;&amp; $scope.email) {
              $http({
                  method: "POST",
                  url: $scope.addLink,
                  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                  headers: {'X-Requested-With' :'XMLHttpRequest'},
                  data: { grant_type: 'password', username: $scope.email, Password: $scope.password }
              }).then(function mySucces(response) {
                  $scope.stateHideError = true;
                  $scope.stateHideSuccess = false;
                  Authorization.go('carInsurance');
              }, function myError(response) {
                  $scope.stateHideError = false;
                  $scope.stateHideSuccess = true;
                  $scope.error = "Wystąpił błąd - Problem z wysłaniem parametrów";
              });
          }
          else {
              $scope.stateHideError = false;
              $scope.stateHideSuccess = true;
              $scope.error = "Wystąpił błąd - nie podałeś wszystkich wymaganych wartości.";
          }
      };
  </code></pre>
  
  <p>PtrScn
  <a href="https://i.stack.imgur.com/LBuV6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LBuV6.png" alt="enter image description here"></a></p>
  
  <p>I would like send something like this </p>
  
  <p><a href="https://i.stack.imgur.com/mCZQ2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mCZQ2.png" alt="enter image description here"></a></p>
  
  <p>I added this to WinApi C#</p>
  
  <pre><code>    &lt;httpProtocol&gt;
          &lt;customHeaders&gt;
            &lt;add name="Access-Control-Allow-Origin" value="*"/&gt;
          &lt;/customHeaders&gt;
      &lt;/httpProtocol&gt;
  </code></pre>
  
  <p>and now I have this error</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://localhost:56305/Token" rel="nofollow noreferrer">http://localhost:56305/Token</a>. Response for
    preflight has invalid HTTP status code 400</p>
  </blockquote>