Linda, web services are stateless by design, meaning that every call you
make will "forget" about any previous call. There are ways around this. If
you want to remember your login variable, you can do the following:
In your login method, create a session variable called "bLogin". You can do
this by saying Session("bLogin") = "true". (Assuming you are using VB. C#
use Session["bLogin"] = true). In all of your web methods, put an
attribute in front of them to make them session aware, and you can then
check bLogin to see if it is true or false. It will remember the value.
VB:
<System.Web.Services.WebMethod(EnableSession:=True )> _
Public Function DoSomething() As Integer
if CType(Session("bLogin"), Boolean) = true then
Return 1
else
Return 2
end if
End Function
C#:
[System.Web.Services.WebMethod(EnableSession=true)]
public int DoSomething()
{
if ((bool) Session["bLogin"] == true)
{
return(1);
}
else
{
return(2);
}
}
"Linda Chen" <li********@faa.gov> wrote in message
news:20*****************************@phx.gbl...
Hello,
I made a webservice, the user is asked to login to the
server before making other calls. I have problem to keep
the login state.
Inside my web service I have a private boolean called
bLogin. When the login is sucessful I set the bool to true.
But when I tested my webservice from my testing program (a
console application), I call login method first, I stepped
through all steps and I knew the blogin had been set to be
true. Then from my testing program I called another web
method by using the same instance of the webservice, the
wired thing happened: the bLogin flag was reset back to
false.
Any idea?
Thanks a lot.
Linda Chen