public ActionResult Login(Models.LoginInfo loginInfo) { if (Session["userToken"] != null) { return(RedirectToAction("Index")); } if (String.IsNullOrEmpty(loginInfo.username) || String.IsNullOrEmpty(loginInfo.password)) { ViewBag.ErrorMessage = "Please provide username & password"; return(RedirectToAction("Login")); } try { string userToken = serviceRef.LoginWithAD(loginInfo.username, loginInfo.password); Session["userToken"] = userToken; return(RedirectToAction("Index")); } catch (FaultException <ServiceReference1.ServiceFault> fault) { ViewBag.ErrorMessage = fault.Detail.Message; return(View()); } }