Master Page and Session null pointer on page load
-
Hello all, After a fare 3 hour of "banging my head on the wall" (and the internet) here is a question for you. I have a master page (surprise surprise) and in it in the
Page_Load
I am trying to pull out some variables from theSession
. However mySession
variable isnull
What am I doing wrong:confused::confused::confused:? Am I missing some configuration issues or permission issues? Thank you! AlbertoAlberto Bar-Noy Project Manager http://www.consist.co.il
-
Hello all, After a fare 3 hour of "banging my head on the wall" (and the internet) here is a question for you. I have a master page (surprise surprise) and in it in the
Page_Load
I am trying to pull out some variables from theSession
. However mySession
variable isnull
What am I doing wrong:confused::confused::confused:? Am I missing some configuration issues or permission issues? Thank you! AlbertoAlberto Bar-Noy Project Manager http://www.consist.co.il
Well... if It's in the onload of the master page, that means it will be among the very first lines of code executed in your application. Thus, it will be checking for the session variable, in all likelyhood, before you can get the chance to set it. Before using the session variable in any way, try checking first to see if it's null, or use a try catch block to stave off unhandled exceptions until you can set the session variable.
-
Hello all, After a fare 3 hour of "banging my head on the wall" (and the internet) here is a question for you. I have a master page (surprise surprise) and in it in the
Page_Load
I am trying to pull out some variables from theSession
. However mySession
variable isnull
What am I doing wrong:confused::confused::confused:? Am I missing some configuration issues or permission issues? Thank you! AlbertoAlberto Bar-Noy Project Manager http://www.consist.co.il
-
Well... if It's in the onload of the master page, that means it will be among the very first lines of code executed in your application. Thus, it will be checking for the session variable, in all likelyhood, before you can get the chance to set it. Before using the session variable in any way, try checking first to see if it's null, or use a try catch block to stave off unhandled exceptions until you can set the session variable.
-
Where can you set the default values for Session Variables? In asp it used to be in the Global.asa file under Session_OnStart, but where do you do it in asp.net?
No matter how long he who laughs last laughs, he who laughs first has a head start!
Strangely in a very similarly named method in the global.asax...
-
Strangely in a very similarly named method in the global.asax...
-
Well... if It's in the onload of the master page, that means it will be among the very first lines of code executed in your application. Thus, it will be checking for the session variable, in all likelyhood, before you can get the chance to set it. Before using the session variable in any way, try checking first to see if it's null, or use a try catch block to stave off unhandled exceptions until you can set the session variable.
dekart_roo wrote:
Well... if It's in the onload of the master page, that means it will be among the very first lines of code executed in your application. Thus, it will be checking for the session variable, in all likelyhood, before you can get the chance to set it.
This is not really accurate (not trying to offend anyone). If you use a master page (with a content page obviously) the order of events (I might miss one) are as follows. Keys: C = content page M = master page 1) Pre_init (C) 2) Page_init (M) 3) Page_init (C) 4) Page_init_complete (C) 5) Page_load (C) 6) Page_load (M) 7) Page_PreRender (M) Part of the reason for the events taking place like this is it gives you the flexibility of manipulating "something" on the master page based of "something" on the content page. Just thought someone might find this usefull.