public ActionResult Login(string userId, string password)
        {
            AccountInfo info = new AccountInfo();

            if (ModelState.IsValid)
            {
                info.userid = userId;
                info.password = password;
                try {
                    using (svcClient = new AccountServiceClient())
                    {
                        if (svcClient.Authenticate(info))
                        {
                            Session["IsAuthenticated"] = true;
                            Session["User"] = userId;
                            return View("LoggedIn");
                        }
                    }
                }
                catch (FaultException<AccountServiceFault> ex)
                {
                    HandleErrorInfo errorInfo = new HandleErrorInfo(ex, "Home", "Login");
                    return View("Error", errorInfo);
                }

            }
            ViewBag.LoginFailed = "Oops... user credential is not matched, please try again!";
            return View();
        }
Exemplo n.º 2
0
        public ActionResult Login(string userId, string password)
        {
            AccountInfo info = new AccountInfo();

            if (ModelState.IsValid)
            {
                info.userid   = userId;
                info.password = password;
                try {
                    using (svcClient = new AccountServiceClient())
                    {
                        if (svcClient.Authenticate(info))
                        {
                            Session["IsAuthenticated"] = true;
                            Session["User"]            = userId;
                            return(View("LoggedIn"));
                        }
                    }
                }
                catch (FaultException <AccountServiceFault> ex)
                {
                    HandleErrorInfo errorInfo = new HandleErrorInfo(ex, "Home", "Login");
                    return(View("Error", errorInfo));
                }
            }
            ViewBag.LoginFailed = "Oops... user credential is not matched, please try again!";
            return(View());
        }