[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(); } }