public ActionResult Index(tblUser model, string returnUrl) { try { // TODO: Add insert logic here var lUser = loginRepository.GetUserById(model); if (lUser != null) { //FormsAuthentication.SetAuthCookie(model.USERNAME, false); //var role = (SimpleRoleProvider)Roles.Provider; //Roles.AddUserToRole(model.USERNAME, "Admin"); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { Session["userId"] = lUser.userId; Session["role"] = lUser.userType; //FormsAuthentication.SetAuthCookie(lUser.userId,false); return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "ব্যবহারকারী অথবা পাসওয়ার্ড সঠিক নয়।"); } return(View()); } catch (Exception exc) { ModelState.AddModelError("", exc.Message); return(View()); } }