title: C# WebApi Login Verification
body: <p>I am using <strong>React Js</strong> as my front-end and <strong>C# WebApi</strong> with my back-end. I am try to use a token at my back-end here.</p>
  
  <p>So here is my code:</p>
  
  <p><strong>React JS</strong></p>
  
  <p><em>Login JS</em></p>
  
  <pre><code>import React, { Component } from 'react';
  import './App.css';
  import logo from './logo.svg';
  import {Button, Card, CardBody, CardGroup, Col, Container, Form, Input, InputGroup, Row} from 'reactstrap';
  import 'bootstrap/dist/css/bootstrap.min.css';
  import axios from 'axios';
  
  class Login extends Component{
    constructor(){
      super();
  
      this.state = {
        UserRole: '',
        UserName: '',
        UserPassword: '',
      }
  
      this.UserPassword = this.UserPassword.bind(this);
      this.UserName = this.UserName.bind(this);
      this.Login = this.Login.bind(this);
    }
  
    UserName(event) {
      this.setState ({ UserName: event.target.value})
    }
  
    UserPassword(event){
      this.setState ({ UserPassword: event.target.value})
    }
  
    Login(event){
      debugger;
      axios.post('http://localhost:60111/Api/login', {
        UserName: this.state.UserName,
        UserPassword: this.state.UserPassword})
      .then(result =&gt; {
        if(result.data.Status === 'Success'){
          console.log(result.data.Status);
          alert("User login Successfully");
          this.props.history.push("/Dashboard");
        }else
        {
          alert('Invalid User');
          this.props.history.push('/Login');
        }
        debugger;
      })
    }
  </code></pre>
  
  <p>I am trying to pass my <em>UserName</em> and <em>UserPassword</em> to my backend C# WebApi.</p>
  
  <p>However, at my <strong>C# WebApi</strong> <em>Login Controller</em>, I try to perform verification action, as below:</p>
  
  <pre><code>namespace mylogin.Controllers
  {
      [RoutePrefix("Api")]
      public class LoginController : ApiController
      {
          DBSecurityTestEntities DBSE = new DBSecurityTestEntities();
          [Route("login")]
          [HttpPost]
          public HttpResponseMessage Login(User user)
          //public object Login(User user)
          {
              bool status = false;
  
              using (DBSE)
              {
                  var obj = DBSE.UserLogins.Where(x =&gt; x.UserName.Equals(user.UserName) &amp;&amp; x.UserPassword.Equals(user.UserPassword)).FirstOrDefault();
                  if (obj != null)
                  //UserLogin ul = new UserLogin();
                  //if (user.UserName == ul.UserName &amp;&amp; user.UserPassword == ul.UserPassword)
                  {
                      status = true;
                  }
                  else
                  {
                      status = false;
                  }
              }
  
              if (status == true)
              {
                  //do something here... perform login and send token
              }
  }
  </code></pre>
  
  <p>However the way I declare it went some error. I tried to put a break point and I checked with the value here
  <a href="https://i.stack.imgur.com/rmxFO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rmxFO.png" alt="enter image description here"></a></p>
  
  <p>So it seems like my data had been successfully pass from front end, however my C# WebApi is unable to perform verification (as my <code>obj</code> is equals to <code>null</code>).</p>
  
  <p>Can someone point out my mistake or omission?</p>