public ActionResult Login(LoginModel model, string ReturnUrl) { try { if (ModelState.IsValid) { var result = _staffBusiness.Login(model); if (result != null) { HttpCookie StaffLoginCookie = new HttpCookie("StaffLoginCookie"); StaffLoginCookie.Value = JsonConvert.SerializeObject(result).UrlEncode(); StaffLoginCookie.Expires = DateTime.Now.AddDays(7); Response.Cookies.Add(StaffLoginCookie); if (ReturnUrl != "" && ReturnUrl != null) { return(Redirect(ReturnUrl.UrlDecode())); } else { return(Redirect("/")); } } } return(View(model)); } catch (Exception) { return(View(model)); } }