asp.net - Session variable getting lost? -
given global.asax.cs:
using system; using system.web; namespace foo.web { public class global : httpapplication { private const string introductionpageshownsessionkey = "introductionpageshownsessionkey"; protected void application_acquirerequeststate(object sender, eventargs e) { showintroductionifnotyetshown(); } private void showintroductionifnotyetshown() { if (httpcontext.current.session != null) { var introductionpageshown = convert.toboolean(session[introductionpageshownsessionkey]); if (!introductionpageshown) { if (request.path.endswith("/introduction.aspx")) { session[introductionpageshownsessionkey] = true; } else { response.redirect("~/introduction.aspx" + request.url.query); } } } } } }
- user hits webapp , shown introduction.aspx
- user continues using webapp few minutes (asp.net_sessionid: ublbhu45ji31e055ywqu0555)
- user falls idle (doesn't perform postbacks) few minutes
- user performs postback
- user shown introduction.aspx
- second inspection of user's asp.net_sessionid cookie still shows ublbhu45ji31e055ywqu0555
why user shown introduction.apsx second time inside same asp.net session? i'm familiar w/ the risk in setting session variables before redirect in same postback, doesn't apply here, right?
keep in mind session has shorter lifetime session cookie being sent browser , id value set in cookie. in fact, browser can continue submit old session id, , server accept , create new session it, if old expired.
the implications being 2 possibilities: 1) session timing out due timeout config value (i know not case in particular instance)
2) we've figured out since in case via comments question: appdomain shutting down or being recycled.
Comments
Post a Comment