473,403 Members | 2,366 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,403 software developers and data experts.

large objects in viewstate - bad idea?

I have some potentially large objects I would like to store in the
viewstate of a user control. Large as in an entire email message. Is
ViewState not the sort of place to store such an object?

I think my question and concern depends on what asp.net does with the
view state when the page is written to the browser. Is the entire
viewstate contents written to the browser as a hidden field? Or are
the view state contents stored on the server and only a key of some
sorts is written to the browser?

thanks,

-Steve

Nov 19 '05 #1
10 1789
ok, I read that the entire viewstate is copied to the browser. So a
million byte email message in viewstate is not a good idea :).

Session state is all server, correct? I can generate a guid key, store
my large serialized object in session state, and store the guid key in
the view state of the user control?

thanks,

-Steve
Steve Richter wrote:
I have some potentially large objects I would like to store in the
viewstate of a user control. Large as in an entire email message. Is
ViewState not the sort of place to store such an object?

I think my question and concern depends on what asp.net does with the
view state when the page is written to the browser. Is the entire
viewstate contents written to the browser as a hidden field? Or are
the view state contents stored on the server and only a key of some
sorts is written to the browser?

thanks,

-Steve


Nov 19 '05 #2
Well, it's not necessarily a bad idea to put large items in ViewState, but
you pay the cost by doing so. Yes it's stored in a hidden input. In ASP.NET
2.0 there's a PageAdapter that can be configured to store the ViewState in
Session state, thus minmizing ViewState. You can do this yourself in v1.x
by overriding SavePageStateToPersistenceMedium and LoadPageStateFromPersistenceMedium.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have some potentially large objects I would like to store in the
viewstate of a user control. Large as in an entire email message. Is
ViewState not the sort of place to store such an object?

I think my question and concern depends on what asp.net does with the
view state when the page is written to the browser. Is the entire
viewstate contents written to the browser as a hidden field? Or are
the view state contents stored on the server and only a key of some
sorts is written to the browser?

thanks,

-Steve


Nov 19 '05 #3
Hi Steve,

Everything is relative <g>...

Viewstate is sent back and forth between the server and the client, so it
gets embedded into the page when it's created and sent back to you when the
form is POSTEd. As you might expect that creates overhead in terms of hte
size of the page being transferred. In addition ASP.NET has to encode
viewstate (both encrypt and then base64 encode if EnableViewStateMac is
true) which also has some overhead.

I try to avoid viewstate whenever I can, but there are some scenarios where
viewstate can be very beneficial in performance and maintaining state on a
page.
+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com
www.west-wind.com/weblog
"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have some potentially large objects I would like to store in the
viewstate of a user control. Large as in an entire email message. Is
ViewState not the sort of place to store such an object?

I think my question and concern depends on what asp.net does with the
view state when the page is written to the browser. Is the entire
viewstate contents written to the browser as a hidden field? Or are
the view state contents stored on the server and only a key of some
sorts is written to the browser?

thanks,

-Steve

Nov 19 '05 #4
Whatever you do, you should consider a compression technique to reduce the
actual amount of data stored.
"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have some potentially large objects I would like to store in the
viewstate of a user control. Large as in an entire email message. Is
ViewState not the sort of place to store such an object?

I think my question and concern depends on what asp.net does with the
view state when the page is written to the browser. Is the entire
viewstate contents written to the browser as a hidden field? Or are
the view state contents stored on the server and only a key of some
sorts is written to the browser?

thanks,

-Steve

Nov 19 '05 #5

Scott M. wrote:
Whatever you do, you should consider a compression technique to reduce the
actual amount of data stored.
is such a thing part of .net?



"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have some potentially large objects I would like to store in the
viewstate of a user control. Large as in an entire email message. Is
ViewState not the sort of place to store such an object?

I think my question and concern depends on what asp.net does with the
view state when the page is written to the browser. Is the entire
viewstate contents written to the browser as a hidden field? Or are
the view state contents stored on the server and only a key of some
sorts is written to the browser?

thanks,

-Steve


Nov 19 '05 #6
Hi,

won't using a compression technique increase the overhead?

Also, This would have to be manually handled by the programmer to compress
the data of the control then put it in viewstate and later to uncompress the
data to process it.
or does Asp.Net provide a easy way to do this?
--
--Vijay R
"Scott M." wrote:
Whatever you do, you should consider a compression technique to reduce the
actual amount of data stored.
"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have some potentially large objects I would like to store in the
viewstate of a user control. Large as in an entire email message. Is
ViewState not the sort of place to store such an object?

I think my question and concern depends on what asp.net does with the
view state when the page is written to the browser. Is the entire
viewstate contents written to the browser as a hidden field? Or are
the view state contents stored on the server and only a key of some
sorts is written to the browser?

thanks,

-Steve


Nov 19 '05 #7
I don't believe so, but there are many 3rd party solutions to this problem.
"Steve Richter" <St************@gmail.com> wrote in message
news:11********************@z14g2000cwz.googlegrou ps.com...

Scott M. wrote:
Whatever you do, you should consider a compression technique to reduce
the
actual amount of data stored.


is such a thing part of .net?



"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
>I have some potentially large objects I would like to store in the
> viewstate of a user control. Large as in an entire email message. Is
> ViewState not the sort of place to store such an object?
>
> I think my question and concern depends on what asp.net does with the
> view state when the page is written to the browser. Is the entire
> viewstate contents written to the browser as a hidden field? Or are
> the view state contents stored on the server and only a key of some
> sorts is written to the browser?
>
> thanks,
>
> -Steve
>

Nov 19 '05 #8
Why would compressing the data increase overhead? I don't believe .NET
includes compression classes, but there are 3rd party classes that can do
this. If you were able to reduce the size of the data by 50% (the OP said
he wants to store text from emails so 50% is very reasonable), the bandwidth
savings would negate the processing time needed to do the compression.
"Vijay" <Vi****@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
Hi,

won't using a compression technique increase the overhead?

Also, This would have to be manually handled by the programmer to compress
the data of the control then put it in viewstate and later to uncompress
the
data to process it.
or does Asp.Net provide a easy way to do this?
--
--Vijay R
"Scott M." wrote:
Whatever you do, you should consider a compression technique to reduce
the
actual amount of data stored.
"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
>I have some potentially large objects I would like to store in the
> viewstate of a user control. Large as in an entire email message. Is
> ViewState not the sort of place to store such an object?
>
> I think my question and concern depends on what asp.net does with the
> view state when the page is written to the browser. Is the entire
> viewstate contents written to the browser as a hidden field? Or are
> the view state contents stored on the server and only a key of some
> sorts is written to the browser?
>
> thanks,
>
> -Steve
>


Nov 19 '05 #9
And if you don't mind using API, there is LZ32.dll (the LZ* functions). :)

"Scott M." <s-***@nospam.nospam> ¼¶¼g©ó¶l¥ó·s»D:Or*************@TK2MSFTNGP09.phx.gb l...
I don't believe so, but there are many 3rd party solutions to this problem.
"Steve Richter" <St************@gmail.com> wrote in message
news:11********************@z14g2000cwz.googlegrou ps.com...

Scott M. wrote:
Whatever you do, you should consider a compression technique to reduce
the
actual amount of data stored.


is such a thing part of .net?



"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
>I have some potentially large objects I would like to store in the
> viewstate of a user control. Large as in an entire email message. Is
> ViewState not the sort of place to store such an object?
>
> I think my question and concern depends on what asp.net does with the
> view state when the page is written to the browser. Is the entire
> viewstate contents written to the browser as a hidden field? Or are
> the view state contents stored on the server and only a key of some
> sorts is written to the browser?
>
> thanks,
>
> -Steve
>


Nov 19 '05 #10
Plus get around the 4K viewstate limit imposed by some proxy server, I would
say.

"Scott M." <s-***@nospam.nospam> ¼¶¼g©ó¶l¥ó·s»D:%2***************@TK2MSFTNGP15.phx. gbl...
Why would compressing the data increase overhead? I don't believe .NET
includes compression classes, but there are 3rd party classes that can do
this. If you were able to reduce the size of the data by 50% (the OP said
he wants to store text from emails so 50% is very reasonable), the
bandwidth savings would negate the processing time needed to do the
compression.
"Vijay" <Vi****@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
Hi,

won't using a compression technique increase the overhead?

Also, This would have to be manually handled by the programmer to
compress
the data of the control then put it in viewstate and later to uncompress
the
data to process it.
or does Asp.Net provide a easy way to do this?
--
--Vijay R
"Scott M." wrote:
Whatever you do, you should consider a compression technique to reduce
the
actual amount of data stored.
"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
>I have some potentially large objects I would like to store in the
> viewstate of a user control. Large as in an entire email message. Is
> ViewState not the sort of place to store such an object?
>
> I think my question and concern depends on what asp.net does with the
> view state when the page is written to the browser. Is the entire
> viewstate contents written to the browser as a hidden field? Or are
> the view state contents stored on the server and only a key of some
> sorts is written to the browser?
>
> thanks,
>
> -Steve
>


Nov 19 '05 #11

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

Similar topics

5
by: Michael Albanese | last post by:
Can you save objects a (custom class) to Viewstate and then get them on a later page?? I have a custom class for an ASP.Net application that I would like to make available across several web...
3
by: Shaul Feldman | last post by:
The question is quiet difficult to explain - I need to give the users ability to append to a table rows, that means I have to reconstruct it every time there's a PostBack i nOnInit event. The...
1
by: igitur | last post by:
Hi all, I have a custom collection derived from System.Collections.Specialized.NameObjectCollectionBase. NameObjectCollectionBase already implements ISerializable, so it should be easy to...
6
by: clsmith66 | last post by:
Is it possible to store the same information about a control that would be saved in the ViewState in a Session state? I have a page with three treeview controls and if I enable the view state for...
0
by: David Helgason | last post by:
I think those best practices threads are a treat to follow (might even consider archiving some of them in a sort of best-practices faq), so here's one more. In coding an game asset server I want...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
1
by: William Sullivan | last post by:
I've got a website that may, on occasion, display a large list of items in a bulletedlist control. On the client side, it takes about 4 seconds to get a response that weighs in at over 1mb. It...
0
by: rmgalante | last post by:
Hi, I've been experimenting with the ASP.Net GridView and encountered some interesting issues that I thought I would share. I have a page that loads a GridView with a generic collection of...
3
by: Jens-Oliver Murer | last post by:
Hello, I have a problem with an ASP.Net-application which generates very large source codes which have to be sent to the clients through 'thin' lines. The main problem seems to be a Datagrid...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.