John Saunders said:
"John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
Hi
C# 2.0.
I have an instance of a web-service assigned to a field, how would I
know if the session has timed-out on that web-service? Is there
anyway of checking this?
When you say, "session", are you referring to session variables, or to
the TCP/IP connection?
Session variables, if I don't access my web-service for 20 minutes and
then attempt to access it I get "Object reference not set to an
instance of an object" exception returned from the service.
So if my session time elapses how would I know without it throwing an
exception?
You should always check to see if session variables are present before
accessing them. I bet you're doing something like:
string variable = Session["Variable"];
if (variable.Length == 0) // If session expired, BOOM
Instead, use String.IsNullOrEmpty(variable) to check. Then do something
intelligent if you find that the session has expired.
Yes, that is what's happening.
The problem is, the web-service is not self-initialising, it must be
"activated" by the client before it can begin to accept certain requests,
this is a bit of a security step to stop any tom, dick and harry from
accessing my service and potentially obtaining sensitive data.
This is why I need to somehow check at the client end, if it has ended I
need to re-activate the service so that I can continue to use it.