Best way to store state on the server?

Discussion in 'ASP .Net Web Services' started by Robin Mark Tucker, May 26, 2006.

  1. 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
    Robin Mark Tucker, May 26, 2006
    #1
    1. Advertising

  2. Robin Mark Tucker

    Josh Twist Guest

    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/
    Josh Twist, May 26, 2006
    #2
    1. Advertising

  3. 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)" <> wrote in
    message news:...
    > 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
    > -------------------
    >
    >
    > "Josh Twist" <> wrote in message
    > news:...
    >> 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, May 31, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Max
    Replies:
    2
    Views:
    431
  2. Tarun Mistry

    Best way to store a time?

    Tarun Mistry, Feb 22, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    312
    Karl Seguin [MVP]
    Feb 22, 2006
  3. Shadow Lynx
    Replies:
    7
    Views:
    1,826
    Shadow Lynx
    Feb 24, 2006
  4. Replies:
    13
    Views:
    10,869
  5. john_c
    Replies:
    11
    Views:
    1,538
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 22, 2007
Loading...

Share This Page