I have the following code in my Global.asax
protected void Application_AcquireRequestState(object sender, EventArgs e) { if (HttpContext.Current.Handler is IRequiresSessionState) { if (Request.IsAuthenticated) { if (HttpContext.Current.Session[this.MemberShipProvider.PrincipalSessionKey] != null) { CxPrincipal principal; try { principal = (CxPrincipal)HttpContext.Current.Session[this.MemberShipProvider.PrincipalSessionKey]; } catch { principal = null; } HttpContext.Current.User = principal; Thread.CurrentPrincipal = principal; } else { var identity = new CxIdentity("admin", 1, "", true); CxPrincipal principalLogin = new CxPrincipal(identity, 1); HttpContext.Current.Session[this.MemberShipProvider.PrincipalSessionKey] = principalLogin; HttpContext.Current.Session[SessionName.CurrentUser] = "Admin User"; HttpContext.Current.User = principalLogin; Thread.CurrentPrincipal = principalLogin; this.FormServiceProvider.SignIn("admin", false);
The problem is that every time Session is an object, the value is null. Not only here, I cannot use sessions in my application either. Either a Reset session, or something like that.
My application no longer requires a login. Therefore, I do not use Session.Clear or Session.Abandon anywhere in my application.
Please help me why my session variable is not set?
source share