|
-
Aug 6th, 2004, 05:32 AM
#1
Thread Starter
Fanatic Member
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.
-
Aug 6th, 2004, 08:33 AM
#2
Fanatic Member
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.
-
Aug 6th, 2004, 08:55 AM
#3
Fanatic Member
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.
-
Aug 6th, 2004, 09:17 AM
#4
Addicted Member
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
-
Aug 9th, 2004, 02:50 AM
#5
Fanatic Member
-
Aug 9th, 2004, 07:18 AM
#6
Fanatic Member
Does the stateserver approach work on XP and can I use this approach on a shared box ?
-
Aug 9th, 2004, 01:39 PM
#7
I wonder how many charact
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.
-
Aug 10th, 2004, 04:00 AM
#8
Fanatic Member
I think you posted to the wrong thread.
-
Aug 10th, 2004, 04:25 AM
#9
Addicted Member
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.
-
Aug 10th, 2004, 05:02 AM
#10
-
Aug 10th, 2004, 06:51 AM
#11
I wonder how many charact
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|