asp.net - .NET Session variable is null - for all users -
problem description
i have asp.net app in users have different rights, , logged in through facebook. app includes (among other things) filling out forms. users have access forms others don't. forms can require searching in books and/or on internet before being able submit them.
as such, we're having problems session time-outs (it seemed), users met "not authorized see page/form" after doing research somewhere else.
attempted solutions
i've created log function logs state of handful of variables on strategic points in application. i've pinpointed problem fact session variable "userrole" null when problem occurs.
relogging
the obvious solution is: "have tried relogging?" - should reset session , allow user form want. on logout, use
session.clear(); session.removeall();
and create new session relevant variables (including userrole) on login. doesn't help, though.
keeping session alive
one way increase standard 20-minute session length arbitrary, higher number (say 2 hours). although viable during beta (there around 5 users right now), not viable solution in long haul server have keep session objects many users longer time, exponentially increasing server demands.
instead, created 'dummy' .ashx handler "refreshsession.ashx", can recieve post request , return "200" statuscode. created jquery function in shared part of app (that pages use) calls handler every 10 minutes in order refresh session long tab open in browser. i've checked network traffic, , works intended, calling handler if window minimized or user viewing tab. did not solve problem either.
a caveat
when 1 of users encounter problem, call me or programming partner up. of course, go , see if same issue. have same (admin) rights. 'funny' thing see exact same error on same subpage - if haven't had contact application days.
the problem 'fix itself' (i.e. let users proper role on subpage) after while, not republishing app server reset manually.
therefore, seems not simpel session error supposed "userrole" session variable being null after 15-20 minutes of inactivity. seems saved somewhere internally in server state.
my problem is, have no idea , how progress. hoping here might have idea solution, or @ least able point me in right direction? :-)
thank time, appreciated.
based on macron's comment question, decided keep information in user's cookies instead of session variables. seemed point having issue, , deadlines being deadlines , me not being able figure out how disable synchronization of worker processes, seemed feasible , comparatively easy fix.
Comments
Post a Comment