public JsonResult JsonLogin(LoginModel model, string returnUrl)
        {
            if (this.ModelState.IsValid) {
                if (Membership.ValidateUser(model.UserName, model.Password)) {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    return this.Json(new { success = true, redirect = returnUrl });
                } else {
                    this.ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed
            return this.Json(new { errors = this.GetErrorsFromModelState() });
        }
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (this.ModelState.IsValid) {
                if (Membership.ValidateUser(model.UserName, model.Password)) {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (this.Url.IsLocalUrl(returnUrl)) {
                        return this.Redirect(returnUrl);
                    } else {
                        return this.RedirectToAction("Index", "Home");
                    }
                } else {
                    this.ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return this.View(model);
        }