views:

30

answers:

2

I built a small ASP.NET application. It has a global.asax and sets some session variables on Session_Start(...).

What could prevent (all) session variables from not being set? Would a session time out do it? What if JavaScript turned off? What else can do it?

A: 

Turning session off in the web.config file or machine.config file would do it (eg. <sessionState mode="Off" />)

Setting EnableSessionState="false" in your Page directives would also do it.

Is this actually happening to you? What do you mean "prevent them from being set". Is Session_Start not firing? Or it's firing, they're being set, and then they're not set later?

womp
+2  A: 

In addition to womp:

  • Not having cookies enabled
  • Redirecting immediately after setting the session variable(s)

I would suspect the second one in particular, especially if you're using any sort of urlrewriting mechanism that does a Response.Redirect.

Chris
Great link! Never seen that problem before... good to know.
Bryan
It sounds like Cookies are the culprit here.
rlb.usa
You can change the cookieless parameter of the session state configuration element to true to force it to rewrite URLs with the session ID, if cookies cannot be re-enabled.
Chris