Hello everyone,
I am totally dumbfounded. I keep getting a null reference to the
HttpContext.Current.Session object and more specifically
HttpContext.Current.Session["CslaPrincipal"]; I see this value get set, but somehow the session object is reset to null. I am using state server.
Here is my global asax code:
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
if (Csla.ApplicationContext.AuthenticationType == "Windows")
return;
System.Security.Principal.
IPrincipal principal;
try
{
//Throwing the null reference here, but does initially work, ??? State Server issue???
principal = (System.Security.Principal.IPrincipal) HttpContext.Current.Session["CslaPrincipal"];
}
catch
{
principal = null;
}
if (principal == null){
// didn't get a principal from Session, so
// set it to an unauthenticted SPrincipal
Synergy.Library.Security.
SPrincipal.Logout();
}else{
// use the principal from Session
Csla.
ApplicationContext.User = principal;
}
Session value is initially set in this code snippet from the index page. I have stepped throught the code and verify that these values are indeed set! However in the midst of running the application the global asax throws a null refererence exception for my HttpContext.Current.Session["CslaPrincipal"] session object.
Synergy.Library.Security.
SPrincipal.Login(user, pw);
userId = Csla.ApplicationContext.User.Identity.Name;
if (Thread.CurrentPrincipal.Identity.IsAuthenticated)
{
HttpContext.Current.Session["CslaPrincipal"] = Thread.CurrentPrincipal;
HttpContext.Current.User = Thread.CurrentPrincipal;
GetAuthorizedCompanyList(userId); //slower on login, but once done lightning fast
FormsAuthentication.RedirectFromLoginPage(user, false);
}
PLEASE HELP, NO IDEA OF WHERE TO EVEN LOOK REGARDING THIS PROBLEM.