We have a web service where we are considering one of two options:
1) Create a new session every time we get a request, execute the request and then kill it, or
2) Create a session when the application is started, maintain this connection on a persistent basis, and re-use this connection over and over.
For the second option, we ran a test where we created the object, and then shut down the server. When we query the object for the IsConnected and IsAuthenticated properties, they don't show anything different. In other words the session object does not know that the server went away.
So the first question is, is there a low overhead way to check to see if the session is still valid?
Second, is a persistent connection not considered to be a best practice?
Third, if we do want a persistent connection, and there is no good way for the session object to know that the server went away, is it better to try to use the (now) invalid session, catch the error, and recover that way? i.e. instead of checking before we try an API operation, try it, let it fail, and deal with it then?