Pooja Chowdhury

Pooja Chowdhury

  • NA
  • 396
  • 39.7k

Why modelstate.isvalid value getting false

Feb 10 2017 2:50 AM
[HttpPost]             public ActionResult Index(MemberInfo MB)         {             if (ModelState.IsValid)             {                 DBAccessLayer.DBdata objDB = new DBAccessLayer.DBdata();                 if (objDB.checkUser(MB.UserName, MB.Password)) // Calls the Login class checkUser() for existence of the user in the database.                 {                     return View("Show", MB); // 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();             }         }

Answers (1)