Can use Session in WebService

  • Thread starter Thread starter ad
  • Start date Start date
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?
 
Yes you can, you have to declare the webmethod like this:
[WebMethod(true)]

:-)
ad ha escrito:
 
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




Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
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

Back
Top