Monday, October 29, 2012

Inspecting WebSessions at Runtime

Every once in a while when working a particularly elusive web application bug, it's nice to be able to see the information stored in the current Session to see if any patterns arise. The easiest way to do this is to add your own variable, like this:

#If DebugBuild then
  Dim sess as WebSession = Session
  Break
#EndIf

You'll notice that I wrapped the variable assignment in an #If DebugBuild pragma statement. In this case, Session is actually a Method which looks up which session is currently active. If calling this method while debugging, you will probably have only one or two sessions to iterate over. On the other hand, if you leave this call in your production code it will have to iterate over all of the active sessions looking for which one is current. The more concurrent sessions you have, the more expensive the call will be in cpu time.

When the debugger comes upon this code, click on the "sess" object and you will see a plethora of information about the connected browser, including:


  • Browser Type
  • Browser Version
  • Client Date/Time
  • Cookie Information
  • The Current Page
  • Hash Tag
  • Platform
  • Protocol (HTTP vs HTTPS)
  • Remote Address
  • The Rendering Engine of the browser

This is a great way to gather information about the computers and browsers that are connecting to your app!

1 comment:

Moris Atwine said...

#SoGood
Really love u softwares guys