Context.Session is found null on postback,

hi,

i am doing some work related to session in the Application_AuthenticateRequest even

when the page load , Current.Session object is perfect.

but when i click on submit of the login page and application_authenticateRequest is called.
is shows curent.session object is null.

how can i get the session object which i stored while login.

Thank
sitgAsked:
Who is Participating?
 
REA_ANDREWConnect With a Mentor Commented:
HttpContext.Current.Session["YourSession"] is the fully qualified version.  You missed of the Context

Andrew
0
 
raterusCommented:
I don't think it's possible to access the Session in Application_AuthenticateRequest
0
 
sitgAuthor Commented:
i mean the same
it is also returning null.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
sitgAuthor Commented:
HttpContext.Current.Session is returing null
0
 
surajgupthaCommented:
Shouldnt the session get established only AFTER a successfull login??
0
 
REA_ANDREWCommented:
ahh I have mis read your question sorry.

Use a cookie to persist the data or


Andrew
Application["YourVariable"] = "YourValue";

Open in new window

0
 
sitgAuthor Commented:
hi,
but i want to store this information only session wise

my requirement is:
on succusfully login i store the iPrinciple object containing the roles in the session and on each request in the  Application_AuthenticateRequest, i want to  get the roles from the session instead of hitting the data store everytime.

but in Application_AuthenticateRequest it is returning "HttpContext.Current.Session" means Session containter itself is null , because my check
" if(HttpContext.Current.Session["aa"]==null) "
is  throwing the exception that "object reference is not set to instance of object"
0
 
sitgAuthor Commented:
my problem is still there.
no answer is resolving my problem
please help
0
 
raterusCommented:
Again, Session is null and will always be null in Application_AuthenticateRequest, find another way.
0
 
sitgAuthor Commented:
thanks .
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.