Can use Session in WebService

A

ad

I add an WebService (.asmx) in a WebApplication.
I have a line :

Session["test"]= "This is a Test";

but it always fail in run time.

Can I use Session in WebService?
 
G

Gonza

Yes you can, you have to declare the webmethod like this:
[WebMethod(true)]

:)
ad ha escrito:
 
J

Juan T. Llibre

re:
Can I use Session in WebService?

Sure you can.

See : http://www.oreilly.com/catalog/prognetws/chapter/ch02.html

ASP.NET web services (classes that derive from System.Web.Services.WebService) exist
within the context of an ASP.NET application and therefore have access to the Application
and Session objects of the ASP.NET application within which they reside.

The session state management mechanism is disabled by default
and can be enabled by setting the EnableSession property to true.

Also, see : http://samples.gotdotnet.com/quickstart/aspplus/doc/servicesandobjs.aspx





ad said:
I add an WebService (.asmx) in a WebApplication.
I have a line :

Session["test"]= "This is a Test";

but it always fail in run time.

Can I use Session in WebService?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top