public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }
        public ActionResult UserLogin(LoginModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    SystemUserDal d = new SystemUserDal();
                    SystemUser u = d.Find(model.UserLogin, CriptographyPass.EncryptMD5(model.UserPassword));
                    if (u != null)
                    {
                        FormsAuthentication.SetAuthCookie(u.UserLogin, false);
                        Session.Add("systemuser", u.UserName);

                        return RedirectToAction("Home", "Admin");
                    }
                    else
                    {
                        ViewBag.Message = "Acesso Negado. Tente Novamente.";
                    }

                }
            }
            catch (Exception ex)
            {

                ViewBag.Message = ex.Message;
            }

            return View("Login");
        }