![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How can I get session state for my user in a web service? I understand that with WinForm clients that this was not necessary, but now with Asp.net Ajax, I can access all the server objects but the session one. I can use the User object but it's a lot of extra work. Is Microsoft employees listening here? Thanks in advance, Donald Adams |
#3
| |||
| |||
|
|
Hi, Donald Adams wrote: How can I get session state for my user in a web service? I understand that with WinForm clients that this was not necessary, but now with Asp.net Ajax, I can access all the server objects but the session one. I can use the User object but it's a lot of extra work. Is Microsoft employees listening here? Thanks in advance, Donald Adams You need to enable the Session state for your web service. By default, they are stateless. Use [WebMethod( EnableSession=true )] Also, see this: http://geekswithblogs.net/lbugnion/a...25/107243.aspx This is also true for web services. HTH, Laurent -- Laurent Bugnion [MVP ASP.NET] Software engineering, Blog: http://www.galasoft-LB.ch PhotoAlbum: http://www.galasoft-LB.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch |
#4
| |||
| |||
|
|
Thanks that worked, but I was hoping I could use the session object in the webservice constructor too. |
#5
| |||
| |||
|
|
"Donald Adams" <BDA_2003 (AT) hotmail (DOT) com> wrote in message news:B382550F-6068-4FEC-BF76-0F9CED9EA64D (AT) microsoft (DOT) com... Thanks that worked, but I was hoping I could use the session object in the webservice constructor too. What prevents you from using it in the constructor? John |
#6
| |||
| |||
|
|
you mean [WebMethod( EnableSession=true )] can be used on the constructor too? I didn't think of the constructor as a method that the client could call. I thought there would be something that would apply to the whole class like: [WebService( EnableSession=true )] but that gives me an error. |
#7
| |||
| |||
|
|
"Donald Adams" <BDA_2003 (AT) hotmail (DOT) com> wrote in message news:AAFE88DA-AEB9-4793-B81D-5EA0E9C4D7CE (AT) microsoft (DOT) com... you mean [WebMethod( EnableSession=true )] can be used on the constructor too? I didn't think of the constructor as a method that the client could call. I thought there would be something that would apply to the whole class like: [WebService( EnableSession=true )] but that gives me an error. Ok, good point. But what do you want to use Session for in the constructor? Were you aware that the constructor will be called on every single web service call? John |
#8
| |||
| |||
|
|
John, yes, I'm aware it will be called everytime, I want to initialize some values that will be used in every web method. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |