Asp.net MVC calling Login web service
<p>I am new to Asp.Net, What i want to do is . I have a Web API for Login service , that returns a json Data.  Sample url of Web APi </p>

<pre><code>http://localhost:55500/api/Login/submit?username=abc&amp;password=abc123
</code></pre>

<p>It returns a json data like </p>

<pre><code>[{"UserID":0,
  "Status":"True",
  "Name":"885032-59-6715",
  "DepName":"Ajay"} 
]
</code></pre>

<p>How can i authenticate my login page in Asp.NET MVC. If login success (Status:True). I should redirect to dashboard and display the json data in my view page.
   If login not successfull, it should show the error message</p>

<p><strong>My ASP.NET MVC model calss File :</strong></p>

<pre><code>namespace LoginPracticeApplication.Models{
  public class Login {

    [Required(ErrorMessage = "Username is required")] // make the field required
    [Display(Name = "username")]  // Set the display name of the field
    public string username { get; set; }

    [Required(ErrorMessage = "Password is required")]
    [Display(Name = "password")]
    public string password { get; set; }       
  }}
</code></pre>

<p><strong>My ASP.NET MVC Controller File :</strong></p>

<pre><code>public ActionResult Index(Login login)
{
  if (ModelState.IsValid) // Check the model state for any validation errors
  {
      string uname = "";
      uname = login.username;
      string pword = "";
      pword = login.password;

      string url = "http://localhost:55506/api/Login/submit?username=" + uname + "&amp;password=" + login.password + "";
      System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
      client.BaseAddress = new Uri(url);
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
      HttpResponseMessage responseMessage = client.GetAsync(url).Result;

      var responseData = responseMessage.Content.ReadAsStringAsync().Result;
      if (responseData=="true")
      {                    
          return View("Show", login); // Return the "Show.cshtml" view if user is valid
      }
      else
      {
          ViewBag.Message = "Invalid Username or Password";
          return View(); //return the same view with message "Invalid Username or Password"
      }
  }
  else
  {
      return View();
  }
  return View();
}
</code></pre>

<p>When i tried to login with this above code. It always shows "Invalid Username or Password". So thanks in advance for your help. Looking forward for success</p>