public static void RegisterApplicationVariables() { lmsConstants oConst = new lmsConstants(); HttpContext.Current.Application["installationid"] = oConst.GetElement("installation"); HttpContext.Current.Application["includethirdparty"] = oConst.GetElement("includethirdparty"); }
public void OnException(ExceptionContext filterContext) { if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest()) { filterContext.HttpContext.Response.StatusCode = 500; filterContext.ExceptionHandled = true; lmsConstants oConst = new lmsConstants(); filterContext.Result = new JsonResult { Data = new { // obviously here you could include whatever information you want about the exception // for example if you have some custom exceptions you could test // the type of the actual exception and extract additional data // For the sake of simplicity let's suppose that we want to // send only the exception message to the client errorMessage = oConst.GetElement("jsonerrormessage") // filterContext.Exception.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } }
public JsonResult UserLogin(LoginData loginData) { JsonResponse response = new JsonResponse(); try { LoginData lData = new LoginData(); //DataSet dt = new DataSet(); lmsConstants lmsConstant = new lmsConstants(); var dt = lData.ValidateLogin(loginData).Tables[0]; if (LWT.Common.LWTSafeTypes.SafeInt64(dt.Rows[0]["loginID"]) > 0) { FormsAuthentication.SetAuthCookie(loginData.UserName, true); HttpCookie cookieUserName = new HttpCookie("MavcPortalUserName"); HttpCookie cookiePassword = new HttpCookie("MavcPortalPassword"); HttpCookie Username = new HttpCookie("Username"); cookieUserName.Value = LWT.Common.LWTSafeTypes.SafeString(dt.Rows[0]["UserID"]); cookieUserName.Expires = DateTime.Now.AddDays(365); cookiePassword.Value = loginData.Password; cookiePassword.Expires = DateTime.Now.AddDays(365); Response.Cookies.Add(cookieUserName); Response.Cookies.Add(cookiePassword); response.Message = "Success"; } return(Json(new { data = response }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { response.Remarks = ex.Message; return(Json(new { data = response }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ValidateLogin(string UserName, string Password, bool RememberMe, string Uniquewindowid) { JsonResponse response = new JsonResponse(); response.Success = false; Boolean firstTimeLogin = false; try { response.Message = "Sign in error. The Mobile Np. you entered is registered. Please try again."; if (UserName == "") { response.Message = "Mobile No. is required"; return(Json(new { response = response }, JsonRequestBehavior.AllowGet)); } if (Password == "") { response.Message = "Password is required"; return(Json(new { response = response }, JsonRequestBehavior.AllowGet)); } Member member = new Member(); DataSet userInfo = member.AuthenticateLogin(UserName, Password, "Mobile"); if (userInfo != null) { DataTable userDataRows = userInfo.Tables[0]; if (userDataRows.Rows.Count > 0) { if (userDataRows.Columns.Contains("UserID")) { FormsAuthentication.SetAuthCookie(UserName, RememberMe); Session.Add("UserID", LWT.Common.LWTSafeTypes.SafeString(userDataRows.Rows[0]["UserID"])); //Session.Add("FirstName", LWT.Common.LWTSafeTypes.SafeString(userDataRows.Rows[0]["FirstName"])); //Session.Add("LastName", LWT.Common.LWTSafeTypes.SafeString(userDataRows.Rows[0]["LastName"])); Session.Add("Uniquewindowid", Uniquewindowid); //firstTimeLogin = !(LWT.Common.LWTSafeTypes.SafeBool(userDataRows.Rows[0]["FirstLogin"])); response.Success = true; response.Message = ""; } //else if (userDataRows.Columns.Contains("LoginLimit")) //{ // response.Remarks = LWT.Common.LWTSafeTypes.SafeString(userDataRows.Rows[0]["Remarks"]); // response.Message = LWT.Common.LWTSafeTypes.SafeString(userDataRows.Rows[0]["LoginLimit"]); //} //else //{ // response.Remarks = LWT.Common.LWTSafeTypes.SafeString(userDataRows.Rows[0]["Remarks"]); // response.Message = LWT.Common.LWTSafeTypes.SafeString(userDataRows.Rows[0]["Error"]); //} } } return(Json(new { response = response, firstTimeLogin = firstTimeLogin }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { lmsConstants oConst = new lmsConstants(); if (oConst.GetElement("debugon") == "1") { response.Message = "System Error" + ex.ToString(); } else { response.Message = "System Error"; } return(Json(new { response = response }, JsonRequestBehavior.AllowGet)); } }