Groups | Blog | Home
all groups > asp.net webservices > may 2006 >

asp.net webservices : Best way to store state on the server?


Josh Twist
5/26/2006 8:09:45 AM
You could store the has in SessionState on the server. That would
probably be an ideal solution as each proxy would represent a session.

Josh
http://www.thejoyofcode.com/
Robin Mark Tucker
5/26/2006 10:55:30 AM
Hi,

How can I store state on the server for each instance of a proxy I use on my
client?


For example if I have, say, as hash table in my services.vb class, with a
web method that creates it:

private m_Hash As Dictionary(Of String, Integer)

<WebMethod()> _
Public Sub CreateHash()

m_Hash.Clear()
m_Hash = new Dictionary(Of String, Integer)

End Sub

<WebMethod()> _
Public Sub AddToHash(ByVal theString as String, ByVal theInteger As
Integer)

m_Hash.Add ( theString, theInteger)

End Sub



and then in my client application, instantiate the generated proxy class:



Dim m_Proxy As New MYSERVICE.service

m_Proxy.CreateHash ()
m_Proxy.AddToHash ( "Example", "1" )


Will the hashtable created in the service when "CreateHash" is executed
still be there when "AddToHash" is executed? As m_Proxy is client side, I'm
wondering if an instance of the service class on the server exists for as
long as it does. What is the "best" practice way to store state like this?

Thanks



Robin Tucker













Gaurav Vaish (EduJini.IN)
5/27/2006 7:02:51 PM
Wondering if the proxy created caches/passes the Cookies sent by the
web-service server?

--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
http://www.edujini.in
-------------------


[quoted text, click to view]

Robin Mark Tucker
5/31/2006 11:24:50 AM

Well I decided to do what Josh said and used session variables. It's quite
handy because I'm able to dump "object" into it, rather than previously in
my (ancient) experience, just strings.



"Gaurav Vaish (EduJini.IN)" <gaurav.vaish.nospam@nospam.gmail.com> wrote in
message news:uZcsZIZgGHA.1260@TK2MSFTNGP05.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button