473,804 Members | 3,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3100
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******** ******@TK2MSFTN GP10.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******@takem pis.com> wrote in message
news:O3******** *****@tk2msftng p13.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******** ******@TK2MSFTN GP10.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
42047
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 datagrid paging. Can I use a static variable? Also, if I use a static variable is that variable shared by everyone that brings up the aspx page? Ex, if 4 people are viewing the aspx page is an instance of the static variable created for each of the...
3
6352
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 to keep those variables, as an alternative, as ViewState variables because I don't want to transfer to many hidden fields. This is the code I use :
4
4151
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 Session = "Bill"; -- This statement will keep this info on the server
4
2522
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" button is clicked. In addition, the session variable is reset to zero when the "Empty" button is pressed. The problem is if the value is non-zero and the page is reloaded the value is incremented. It appears as if the "Add" onClick event...
6
1624
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
21143
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 share information across pages but have lots of information to cache for that page.Can you please advise which is the efficient way to do it.The page is a search function which has a minimum of 10000 visitors per day. Regards
17
4985
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 asp.net app (written in C#) running which has the only purpose of rendering a page with a "Next" button on it and some status info. When the user clicks the next button, an event is written to the
2
1954
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 in memory (in process or out of process) - can be configured to store the session data in sql server (which relates to my question) ViewState - Page (but can be modified to overwrite the storage mechanism to store viewstate else where, esp...
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10324
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7623
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.