title: Response for preflight has invalid HTTP status code 405 with asp.net web api and Angular 2
body: <p>i was trying to integrate my asp.net web api with angular 2.for checking login credential in a basic way. 
  asp.net web api code is</p>
  
  <pre><code>public void postvalidUser(string UserName, string Password)
          {
              try
              {
                  var login = uData.Users.Where(x =&gt; x.UserName == UserName).ToList();
                  if (login != null &amp;&amp; login.Count &gt; 0)
                  {
                      foreach (var log in login)
                      {
                          if (log.UserName == UserName &amp;&amp; log.Password == Password)
                          {
                              Console.WriteLine("login ok");
  
                          }
  
                      }
                  }
                  else
                  {
                     Console.WriteLine("login fail");
  
                  }
  
              }
  
              catch (Exception ex){
  
                  Console.WriteLine(ex);
              }
  
          }  
  </code></pre>
  
  <p><strong>login.service.ts file is as:-</strong></p>
  
  <pre><code>@Injectable()
  export class LoginService {
  
    constructor(private _http: Http) { }
    postvalidUser(UserName: string, Password: string) {
  
  
      let headers = new Headers({ 'Content-Type': 'application/json' });
      let options = new RequestOptions({headers: headers });
  
      const users = { UserName: UserName, Password: Password };
      return this._http
        .post("http://localhost:65440/api/User", users, options)
        .map(result =&gt; result.json());
    }
  
    }
  </code></pre>
  
  <p><strong>login.component.ts</strong></p>
  
  <pre><code>export class LoginComponent implements OnInit {
  
  
    constructor(private _loginservices: LoginService) {  }
  
    ngOnInit() {
    }
    OnClick(UserName: string, Password:string) {
      this._loginservices.postvalidUser(UserName, Password).subscribe(users =&gt; console.log(users));
  
    }
  
  
  
  
  
  }
  </code></pre>
  
  <p>now when i m running my app it showing me the error as</p>
  
  <p>Failed to load "my-url": Response for preflight has invalid HTTP status code 405 &amp;&amp;  OPTIONS "my-url" 405 (Method Not Allowed)</p>
  
  <p>Please tell me whether my code is wrong or something is missing.</p>