J
Jeff User
Hello
I am hoping someone knows the answers I seek..
I am writing code in a C# web service solution.
I want to create an instance of an object (that I created) in a
Session variable. I need to check to see if the Session variable has
been set yet. If the variable already contains an instance of this
object then I will retrieve and use the existing object, rather than
create a new instance. ie. I will only create a new object the first
time the procedure is called, and then save it for the next time.
So, in an article I found in my MSDN help entitled
"Code: Reading Values From Session State (Visual C#)"
the procedure recommended to check to see if the Session var was set
yet, is this:
if (Session["SomeVarName"] == null)
When I do this, I get the
"Object reference not set to an instance of an object" error.
Checking in debug, pointing to the word Session, the following
information pops up:
Session = <undefined value>
I thought Session was supposed to be created first thing when a page
is accessed. So, how come mine is not defined yet?
Could it be because it is an .asmx file rather than an aspx file?
If asmx pages don't create a Session object, is there a way to
maintain session information in a web service?
Thanks much
Jeff
I am hoping someone knows the answers I seek..
I am writing code in a C# web service solution.
I want to create an instance of an object (that I created) in a
Session variable. I need to check to see if the Session variable has
been set yet. If the variable already contains an instance of this
object then I will retrieve and use the existing object, rather than
create a new instance. ie. I will only create a new object the first
time the procedure is called, and then save it for the next time.
So, in an article I found in my MSDN help entitled
"Code: Reading Values From Session State (Visual C#)"
the procedure recommended to check to see if the Session var was set
yet, is this:
if (Session["SomeVarName"] == null)
When I do this, I get the
"Object reference not set to an instance of an object" error.
Checking in debug, pointing to the word Session, the following
information pops up:
Session = <undefined value>
I thought Session was supposed to be created first thing when a page
is accessed. So, how come mine is not defined yet?
Could it be because it is an .asmx file rather than an aspx file?
If asmx pages don't create a Session object, is there a way to
maintain session information in a web service?
Thanks much
Jeff