在viewstate中的大对象 - 坏主意? [英] large objects in viewstate - bad idea?

查看:56
本文介绍了在viewstate中的大对象 - 坏主意?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户控件的

视图状态中存储一些可能很大的对象。与整个电子邮件中一样大。

ViewState不是存储这样一个对象的地方吗?


我认为我的问题和关注取决于asp.net对
查看页面写入浏览器时的状态。将整个

视图状态内容作为隐藏字段写入浏览器吗?或者是

存储在服务器上的视图状态内容,只有一些

排序的密钥被写入浏览器?


谢谢,


-Steve

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

推荐答案

好的,我看了整个viewstate被复制到浏览器。所以在viewstate中一个
百万字节的电子邮件消息不是一个好主意:)。


会话状态是所有服务器,对吗?我可以生成一个guid键,在会话状态下存储我的大型序列化对象,并将guid键存储在

用户控件的视图状态中?


谢谢,


-Steve

史蒂夫里希特写道:
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:
我有一些潜在的大对象我想存储在用户控件的视图状态中。与整个电子邮件中一样大。是不是ViewState不是存储这样一个对象的地方?

我认为我的问题和关注取决于asp.net在页面是什么时使用
视图状态写入浏览器。整个
viewstate内容是否作为隐藏字段写入浏览器?或者是存储在服务器上的视图状态内容,只有一些关键字被写入浏览器?

谢谢,

- Steve
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






嗯,在ViewState中放置大件物品并不一定是个坏主意,但

你这样做是为了支付费用。是的,它存储在隐藏的输入中。在ASP.NET

2.0中,有一个PageAdapter可以配置为将ViewState存储在

会话状态中,从而最小化ViewState。你可以通过覆盖SavePageStateToPersistenceMedium和LoadPageStateFromPersistenceMedium在v1.x

中自己完成。


-Brock

DevelopMentor
http://staff.develop.com/ballen
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
我想在用户控件的
视图状态中存储一些可能很大的对象。与整个电子邮件中一样大。是不是ViewState不是存储这样一个对象的地方?

我认为我的问题和关注取决于asp.net在页面是什么时使用
视图状态写入浏览器。整个
viewstate内容是否作为隐藏字段写入浏览器?或者是存储在服务器上的视图状态内容,只有一些关键字被写入浏览器?

谢谢,

- 史蒂夫
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






你好Steve,


一切都是相对的< g> ...


Viewstate在服务器和客户端之间来回发送,因此当它被创建并发回给你时,它会嵌入到页面中当

表格是POSTEd时。正如您所预料的那样,在传输页面的大小方面会产生开销。另外ASP.NET必须编码

viewstate(如果EnableViewStateMac是

,则加密然后是base64编码),这也有一些开销。

我尽量避免使用viewstate,但是在某些情况下,

viewstate在性能和维护状态上非常有利于

页面。

+++ Rick ---


-


Rick Strahl

West Wind Technologies
www.west-wind.com www.west-wind.com/weblog

Steve Richter <圣************ @ gmail.com>在消息中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ...
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...
我想在用户控件的
视图状态中存储一些可能很大的对象。与整个电子邮件中一样大。是不是ViewState不是存储这样一个对象的地方?

我认为我的问题和关注取决于asp.net在页面是什么时使用
视图状态写入浏览器。整个
viewstate内容是否作为隐藏字段写入浏览器?或者是存储在服务器上的视图状态内容,只有一些关键字被写入浏览器?

谢谢,

- 史蒂夫
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



这篇关于在viewstate中的大对象 - 坏主意?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆