Store viewstate in session?

  • Thread starter Joakim Westman \(Elicit AB\)
  • Start date
J

Joakim Westman \(Elicit AB\)

Hi!
I have a page that generates a lot of HTML, and I am considering different
solutions to constrain the amount of
code that is sent back to the client.

One thing I thought about is the viewstate which is fairly large for this
application.

Does anybody have any experience on storing viewstate in Session.

I know that sessionState has a mode for storing inProc, SqlServer etc, but I
doesn't seem like viewstate has come this far yet.
I know there are methods to override to do this, but will it work out you
think?

Cheers,
// Joakim W

_________________________________________ Joakim Westman ICQ#:149175359
Current ICQ status: SMS: (Send an SMS message to my ICQ): +2783142149175359
More ways to contact me: http://wwp.icq.com/149175359
_________________________________________
 
S

Scott Allen

IMHO - keeping Viewstate in Session is going to require a good chunk
of memory on the server. I think it would work for a small number of
users - but not knowing your app or user base its hard to tell where
the line would be drawn. I'm sure it would limit your scalabiity.

Check out "The ASP.NET View State"
http://msdn.microsoft.com/msdnmag/issues/03/02/cuttingedge/

There is a discussion on keeping viewstate server side and some pros
and cons.
 
K

Kevin Spencer

Kind of like storing a box inside a box, don't you think? Perhaps just the
times IN the box...

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
C

Cowboy \(Gregory A. Beamer\)

Joakim Westman (Elicit AB) said:
Hi!
I have a page that generates a lot of HTML, and I am considering different
solutions to constrain the amount of
code that is sent back to the client.

One thing I thought about is the viewstate which is fairly large for this
application.

This is certainly possible. Before making this determination, look at the
actual size of the code sent by getting the file size out of your Internet
cache. You may find that, despite looks, it is only a few kb.
Does anybody have any experience on storing viewstate in Session.

If you mean actually storing that string in Session? Hold out your knuckles!
Whack! Whack! Whack!

If you mean storing the info/variables, sure, you can do that. Consider some
different store, however, as it is unlikely you are using all of the info
with every page hit. Only store stuff in session that is used very
frequently. The rest should be put in a persistant store, like a database.
I know that sessionState has a mode for storing inProc, SqlServer etc, but I
doesn't seem like viewstate has come this far yet.
I know there are methods to override to do this, but will it work out you
think?

ViewState will NEVER come "this far". ViewState is a method of working state
into a stateless environment. As the entire contents are stored in an
encrypted string, you do not need anything else to complete a transaction
with the user. You do not need session state, you do not need
authentication. Etc. Etc. It is not the best method for every application,
however.

The basic idea here is ViewState is meant to be sent to the client, period.
Storing in Session, SQL Server, et al, puts the data on the Server, not the
client. This is not the design goal for ViewState.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
M

mikeb

Joakim said:
Hi!
I have a page that generates a lot of HTML, and I am considering different
solutions to constrain the amount of
code that is sent back to the client.

One thing I thought about is the viewstate which is fairly large for this
application.

Does anybody have any experience on storing viewstate in Session.

I know that sessionState has a mode for storing inProc, SqlServer etc, but I
doesn't seem like viewstate has come this far yet.
I know there are methods to override to do this, but will it work out you
think?

Cheers,
// Joakim W

_________________________________________ Joakim Westman ICQ#:149175359
Current ICQ status: SMS: (Send an SMS message to my ICQ): +2783142149175359
More ways to contact me: http://wwp.icq.com/149175359
_________________________________________

This article:

http://www.aspalliance.com/articleViewer.aspx?aId=135&pId=

has very brief examples showing how to override

SavePageStateToPersistenceMedium() and
LoadPageStateFromPersistenceMedium()

to store viewstate somewhere other than a hidden form field. You can
use a database, or store it in the Session collection.
 
J

Joakim Westman \(Elicit AB\)

Hi!
Thank you all for sharing your views on this topic.
I guess I will do some tests to verify this now.

Cheers,
// Joakim W
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top