// GET: Employee/Details/5 public ActionResult Details(int?id) { if (id == null) { return(RedirectToAction("Index", "Home")); } Employee emp = null; if (ModelState.IsValid) { emp = EmpContext.GetEmployee(id.Value); } // Go to home page if model is not valid return(View(emp)); }