473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Session VS. ViewState For Small Value

Just wondering if there are any strong arguments one way or the other for
storing a small value (6 bytes) in the ViewState vs. Session state. The
value is needed in only one page in a large ASP.NET app. I'm interested in
knowing performance differences specifically and anything a beginning
ASP.NET developer might not be thinking about. FWIW: I'm *not* considering
the 3rd obvious option - cookies.

Thanks!
Nov 18 '05 #1
2 3069
Session State is useful for storing values that must be persisted across
multiple pages by the same user. ViewState is useful for storing
serializable data that must be persisisted across PostBacks by a single
page. If you use Session State, the value you insert will remain in memory
until (1) The Session times out, or (2) Your code removes it. If you use
ViewState, the value you insert will remain in ViewState until the user
requests a different page.

ViewState stores data betwen PostBacks by putting it into a hidden form
field on the client HTML doc. when the doc is Posted Back, the values are
read from the hidden form field and stored in memory until the page has
finished processing. If ViewState is particularly large (and I'm talking KBs
here, not 6 bytes), it can negatively affect the speed at which the HTML doc
is downloaded by the browser.

Use the right tool for your job. I think after my explanation, it should be
obvious that you would want to use ViewState in your specific case.

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

"Fred Newton" <a@b.com> wrote in message
news:OH**************@TK2MSFTNGP10.phx.gbl...
Just wondering if there are any strong arguments one way or the other for
storing a small value (6 bytes) in the ViewState vs. Session state. The
value is needed in only one page in a large ASP.NET app. I'm interested in
knowing performance differences specifically and anything a beginning
ASP.NET developer might not be thinking about. FWIW: I'm *not* considering
the 3rd obvious option - cookies.

Thanks!

Nov 18 '05 #2
<< I think after my explanation... >>
Perfectly clear - thanks!
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:O3*************@tk2msftngp13.phx.gbl...
Session State is useful for storing values that must be persisted across
multiple pages by the same user. ViewState is useful for storing
serializable data that must be persisisted across PostBacks by a single
page. If you use Session State, the value you insert will remain in memory
until (1) The Session times out, or (2) Your code removes it. If you use
ViewState, the value you insert will remain in ViewState until the user
requests a different page.

ViewState stores data betwen PostBacks by putting it into a hidden form
field on the client HTML doc. when the doc is Posted Back, the values are
read from the hidden form field and stored in memory until the page has
finished processing. If ViewState is particularly large (and I'm talking KBs here, not 6 bytes), it can negatively affect the speed at which the HTML doc is downloaded by the browser.

Use the right tool for your job. I think after my explanation, it should be obvious that you would want to use ViewState in your specific case.

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

"Fred Newton" <a@b.com> wrote in message
news:OH**************@TK2MSFTNGP10.phx.gbl...
Just wondering if there are any strong arguments one way or the other for storing a small value (6 bytes) in the ViewState vs. Session state. The
value is needed in only one page in a large ASP.NET app. I'm interested in knowing performance differences specifically and anything a beginning
ASP.NET developer might not be thinking about. FWIW: I'm *not* considering the 3rd obvious option - cookies.

Thanks!


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Wayne | last post by:
Hi, I'm new to .NET and have a question about the use of static variables vs. session variables in a web form in C#. Instead of using a session variable to hold a string to persist during...
3
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want...
4
by: Ralph Krausse | last post by:
ViewState = "Bill"; -- This statement will send that to the browser and hash it into the __VIEWSTATE hidden varible Application = "Bill"; -- This statement will keep this info on the server ...
4
by: N. Demos | last post by:
Hello, I'm learning ASP.NET, and am having a strange problem with some example code from the book I'm using. The code increments and displays the value stored in a session variable when the "Add"...
6
by: Max | last post by:
I need an vb.net class that is invoked from aspx page, that use the viewstate/session object. This class must be store the information into viewstate/session. Can you give me an example ? Thanks
28
by: Vishwanathan Raman | last post by:
Hi I am aware of the technical differences.But would like to get it clarified.Given an oppurtunity is ViewState storage more efficient than Session based.I do not have a scenario where I need to...
17
by: Riaan | last post by:
Hi guys! I have an issue that needs urgent resolution. Imagine this scenario: You have: 1 production server running Windows Server 2003, IIS6 and an instance of MSDE 2000. There is an...
2
by: LeAnne | last post by:
My question is to do with scalability and the location for storate of cache, session, viewstate and application data. Application - Data is stored in memory (in process) Session - Data is stored...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.