How do I test my session-expiry code with VS2010http://forums.asp.net/t/1788858.aspx/1?How+do+I+test+my+session+expiry+code+with+VS2010Wed, 04 Apr 2012 03:38:05 -040017888584914851http://forums.asp.net/p/1788858/4914851.aspx/1?How+do+I+test+my+session+expiry+code+with+VS2010How do I test my session-expiry code with VS2010 <p>I have a problem on a page if the session expires.&nbsp; I think I can solve the problem with code that tests for a new session: -</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim NewSession As Boolean<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim httpApplication As New HttpApplication<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If httpApplication.Session.IsNewSession = True Then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NewSession = True<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NewSession = False<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Not Page.IsPostBack OrElse NewSession = True Then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp; do first time code .....</p> <p>This should execute my first-time code when the session has expired, as well as a genuine Not Postback.</p> <p>How do I test this with Visual Studio?&nbsp; I read somewhere that VS debugger sessions don't expire, so unless I use the production environment for testing (obviously not a good idea) I can't just start a test and wait 20 minutes.</p> <p>Thank you, Robert.</p> <p></p> 2012-04-03T23:31:01-04:004914917http://forums.asp.net/p/1788858/4914917.aspx/1?Re+How+do+I+test+my+session+expiry+code+with+VS2010Re: How do I test my session-expiry code with VS2010 <p>Correction, my code doesn't work. The statement<br> &nbsp;&nbsp;&nbsp; If httpApplication.Session.IsNewSession = True Then ...<br> thows an error: </p> <h3 class="post-title entry-title">Session state is not available in the current context</h3> <p><br> <br> </p> 2012-04-04T01:48:05-04:004914964http://forums.asp.net/p/1788858/4914964.aspx/1?Re+How+do+I+test+my+session+expiry+code+with+VS2010Re: How do I test my session-expiry code with VS2010 <p>This worked.&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim NewSession As Boolean = False<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Not Page.IsPostBack Then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Session(&quot;Table_aspx_session&quot;) = &quot;Exists&quot;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf IsNothing(Session(&quot;Table_aspx_session&quot;)) Then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NewSession = True&nbsp; '&nbsp;&nbsp; It must have timed out<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If</p> <p>It was safe enough, so I tested in on the production site.&nbsp; The name of the session variable, &quot;Table_aspx_session&quot; ensures that it is unique to this page which is table.aspx.&nbsp; </p> <p></p> 2012-04-04T03:38:05-04:00