title: How to display wrong username password on login form ?
body: <p>I am developing the MVC application.
  I have designed the login form. </p>
  
  <p>when user enters the proper username and password then, it redirect to next page, but when user put wrong username or password I want to display the message on the login form, how to do it. </p>
  
  <p>This is the code of method in controller...</p>
  
  <pre><code> [HttpPost]
          public ActionResult LoginUser(FormCollection oFormCollection)
          {
              string userName = oFormCollection["username"];
              string password = oFormCollection["password"];
              bool IsAccountPerson = false;
              var validEmployee = (from e in db.Employees
                                   where e.UserName == userName &amp;&amp; e.Password == password
                                   select e).ToList();
              if (validEmployee.Count() == 1)
              {
                  foreach (var v in validEmployee)
                  {
                      oEmployee = v;
                      Session["LoggedEmployee"] = oEmployee;
                      Session["loggedEmpId"] = oEmployee.Id;
  
                      if (oEmployee.DesignationType == "Account")
                      {
                          IsAccountPerson = true;
                      }
                      else
                      {
                          IsAccountPerson = false;
                      }
                  }
                 if(IsAccountPerson)
                     return RedirectToAction("PaymentAdviceListForAccounts", "Account");
                 else
                    return RedirectToAction("Index", "PaymentAdvice");
  
              }
              else
                  return PartialView("Index");
          }
  </code></pre>
  
  <p>and this is my view Code....</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;   
      &lt;link href="@Url.Content("~/Content/bootstrap.css")" rel="stylesheet" type="text/css" /&gt;
  
  
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  
  
  @using (Html.BeginForm("LoginUser","Login",FormMethod.Post))
  
  {
      @*&lt;div style="margin:15% 20% 20% 30%; width:35%;min-height:25%;border:1px #ACACAC solid;"&gt;*@
  
      &lt;div class="container-fluid" style="padding-left:0px; margin-top:165px; margin-left:140px;"&gt;            
  
  
  
  
                  &lt;div class ="span3"&gt;
                      &lt;label style="font-size:15px; color:#666666;  margin-top:5px;"&gt;Username&lt;/label&gt;
                  &lt;/div&gt;
  
                  &lt;div class ="span6"&gt;
                      &lt;input type="text" id="username" name="username" style="height:20px; width:100%;" /&gt;
                  &lt;/div&gt;
  
  
  
  
                  &lt;div class ="span3"&gt;
                      &lt;label style="font-size:15px;color:#666666; margin-top:5px; "&gt;Password&lt;/label&gt;
                  &lt;/div&gt;
  
                  &lt;div class ="span6"&gt;
                      &lt;input type="password" id="password" name="password" style="height:20px;  width:100%;"/&gt;
                  &lt;/div&gt;
  
  
  
  
  
              &lt;div class="span6" style="padding-left:15px;"&gt;
                    &lt;input type="submit" name="submit" value="Login" class="btn btn-primary" style="margin-right:10px; height:30px; font-size:14px; width:55px;" /&gt;
               &lt;input type="button" name="Login" value="Cancel" class="btn btn-primary" style="margin-right:20px; height:30px; font-size:14px; width:55px; padding-left:5px; padding-right:5px;" /&gt;
               &lt;/div&gt;
  
  
          &lt;/div&gt;
         &lt;/div&gt;
       &lt;/div&gt;
  
    &lt;/div&gt;
  
  }
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>