Results 1 to 11 of 11

Thread: how to persist data across multiple pages.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    how to persist data across multiple pages.

    The situation is this:
    The first page has 12 text boxes on and and a list box.
    I need to navigate through a few pages other pages and retain the data from the first page the user entered.

    Its a bit of a faff to use 12 session variables.

    Does anyone know how to store arrays in session variables. I have tried and when i retrieve the array I get the message
    Cannot convert system.array to a 1 dimensional array of string. This is because I have Option strict switched on.
    I need an array because I have a list of id the user enters.


    Things I do when I am bored: DotNetable

  2. #2
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    There are different kinds of session state. The default will not allow you to store in session state complex objects.

    There is a way of storing complex objects in session state but I wont claim to know much about them. Here at work I place entire tables and datasets in sessionstate.

    I'm sure a bit of research on session state will be rewarded.

    You could also use a database to store state info (sql server at least).

    You may want to look at ViewState as well.
    Last edited by venerable bede; Aug 6th, 2004 at 08:42 AM.

    Parksie

  3. #3
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    The kind of session state you need is StateServer.

    In your web config you will add this
    <sessionState mode="StateServer" stateConnectionString=

    Just google StateServer for details.

    The sql server form of session state you will only use whern you are developing on a webfarm as you will be unable to retain state across domains.

    Parksie

  4. #4
    Addicted Member
    Join Date
    Dec 2002
    Posts
    175
    Bit of info:

    session state is inprocess - if IIS crashes you loose state
    stateserver is out of process if IIS crashes state saved - separate proc running on NT (possibly another machine) and may serve several IIS servers for common state across servers
    SQL server state out of process - similar to stateserver

  5. #5
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Thumbs up

    Cheers !

    Parksie

  6. #6
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Does the stateserver approach work on XP and can I use this approach on a shared box ?

    Parksie

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    The problem as I see it, is simply getting your array to a describable string (xml).

    You should create a class that can serialize to xml.

  8. #8
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    I think you posted to the wrong thread.

    Parksie

  9. #9
    Addicted Member
    Join Date
    Dec 2002
    Posts
    175
    The exe for stateserver is held at:

    systemroot\Microsoft.NET\Framework\versionNumber\aspnet_state.exe

    So run this on the machine which is to hold state as a service.
    In the config of your web apps you need to configure to use it:

    eg
    <sessionState mode="StateServer"
    stateConnectionString="tcpip=YourSvrRunningStateSvr:42424"
    cookieless="false"
    timeout="20"/>
    </sessionState>
    Where you supply the name of the server and port in the stateconnstring.

    The SQL method requires you to run a couple of SQL against your SQL server found in
    systemroot\Microsoft.NET\Framework\versionNumber -->
    InstallSqlState.sql or InstallPersistSqlState.sql

    There are 2 scripts one creates state table in temp tables which means that if the SQL Server restartes you wipe all the session data.
    Config eg

    <configuration>
    <system.web>
    <sessionState mode="SQLServer"
    sqlConnectionString=" Integrated Security=SSPI;data source=YourSQLServer;"
    cookieless="false"
    timeout="20"/>
    </sessionState>
    </system.web>
    </configuration>

    Hope this all helps! Let us know how you get on.

    PS I'm going to be away for a few weeks so don't be offended if I don't speak for a while.

  10. #10
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018
    Thanks.

    Parksie

  11. #11
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Originally posted by venerable bede
    I think you posted to the wrong thread.
    I was answering the original author's question

    He wants to put an array into session state, but session only allows simple objects... like strings.

    So to put an array in session state, he needs to create something that can be stored there... like a descriptive XML string.

    I had a distant related problem trying to pass a 2-dimensional array from a webservice (they only return simple objects easily)

    http://www.vbforums.com/showthread.p...ighlight=array

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width