Im using outproc session that is managed by aspnet_state. Sometimes I get run time errors saying that the session is invalid. So I wanted to check if the session is valid for every request I make. But I couldn’t find a proper way to do it like in this Question using Java.
Here is the code I’m using right now in the page_preinit event.It looks ugly but it works.
Try
Dim x = Session.Keys().Item(0)
Catch ex As Exception
Session.Clear()
End Try
Does any one knows a better approach?
Thanks
Actually I solved the problem by checking the first element of the session( session.item(0) )
I put the code in try catch . if the there is an exception I just clear the session. This code is in a basepage for all my pages.
so in the preinit event my code look like this
It seems to be ugly but it does solve my problem.
Thanks everyone.