title: How to check if asp session is valid?
body: <p>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 <a href="https://stackoverflow.com/questions/634929/how-to-check-if-a-session-is-invalid">this Question</a> using Java.</p>
  
  <p>Here is the code I'm using right now in the page_preinit event.It looks ugly but it works.</p>
  
  <pre><code>            Try
                  Dim x = Session.Keys().Item(0)
              Catch ex As Exception
                  Session.Clear()
              End Try
  </code></pre>
  
  <p>Does any one knows a better approach? </p>
  
  <p>Thanks</p>