public JsonResult JsonExternalLogin(LoginModel model, string ReturnUrl) { if (ModelState.IsValid) { //Step 1: Get data from Sp and check it AccountBL Ab = new AccountBL(); ContactDetails cd = new ContactDetails(); cd = Ab.CheckLogin(model.UserName, model.Password); if (cd.CustomerID > 0) { //cd.CustomerID = 0; FormsAuthentication.SetAuthCookie(model.UserName, false); SiteSession siteSession = new SiteSession(cd); SessionHelper.UserSession = siteSession; UrlHelper u = new UrlHelper(HttpContext.Request.RequestContext); string url = string.Empty; if (SessionHelper.UserSession.RoleID == UserRole.SuperAdmin || SessionHelper.UserSession.RoleID == UserRole.Admin|| SessionHelper.UserSession.RoleID == UserRole.Staff) url = u.Action("Index", "Search", null); else url = u.Action("Index", "SetupCustomer", null); return Json(new { success = true, redirect = string.IsNullOrEmpty(ReturnUrl) ? url : ReturnUrl }); } else { ModelState.AddModelError("", "Please provide valid User Name/Password."); } } return Json(new { errors = KeyValue.GetErrorsFromModelState(ViewData) }); }