Ales,
HttpContext.Current gives you, as name implies, http call context for the
current call. If you need to preserve some information between two calls to
your web service you can use either cookies or session state. Session state
is easier to implement, but can give you some performance drop. If your web
service doesn't have high number of the requests, you can use sessions.
Technically, you'll need to enable session state in web.config like so:
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="20"
/>
Most likely this xml node is already present in your web.config. Once it is
there, you can run "session-enabled" web methods, for example (C# example
from Visual Studio.NET help on WebMethod.EnableSession property):
[WebMethod(Description="Per session Hit Counter",EnableSession=true)]
public int SessionHitCounter()
}
if (Session["HitCounter"] == null)
{
Session["HitCounter"] = 1;
}
else
{
Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
}
return ((int) Session["HitCounter"]);
}
--
Vitaly.
-------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Ales Pour said:
Hi,
I try to put some custom objects into HttpContext.Current.Items collection
in one-way webmethod, but they seem not to be there in another invocation.
Is it supposed to work?
Thank you!
Regards,
Ales Pour