public ActionResult Login(DLAdmin ad, string ReturnUrl = "") { try { if (!string.IsNullOrEmpty(ad.Email) && !string.IsNullOrEmpty(ad.Password)) { if (bal.IsValid(ad.Email, ad.Password, "CheckValid")) { BLAdmin bal = new BLAdmin(); FormsAuthentication.SetAuthCookie(ad.Email, true); var dal = bal.LoadData(); foreach (var e in dal) { if (e.Email == ad.Email) { Session["Role"] = e.Role; Session["Photo"] = e.Photo; break; } } if (Url.IsLocalUrl(ReturnUrl)) { return(Redirect(ReturnUrl)); } else { return(Redirect("/Home/Dashboard")); } } else { TempData["Error"] = "Invalid Email Id Or Password"; } } else { TempData["Error"] = "Required Email Id Or Password"; } } catch (Exception ex) { throw ex; } return(View()); }