Debugging an operation that’s performing slowly, I’ve discovered (to my astonishment) that the line:
if (HttpContext.Current.Session["CurrentCompany"] == null)
takes about 30 seconds to execute.
What could possibly be happening!? Anyone seen anything like this before?
(It’s in a loadbalanced config with StateServer storing session, could that be related?)
I found a workaround: I changed the session provider in the web.config:
from “StateServer” to “InProc”:
… and the pause went away.
(Most likely it had trouble reaching the stateserver, the current server is not where it was originally running from).
Thanks to all your suggestions, especially @Hari and @dougajmcdonald.
.
Hindsight edit
This may help someone later: The root cause of this issue seems to have been a method that made a huge number of very heavy SQL queries that occurred around the same time as this stateserver problem. I think these are related, not exactly sure how. I’ve had similar problems since, so if you have a session issue like this, look for heavy DB activity.