ViewState与Session [英] ViewState vs Session

查看:63
本文介绍了ViewState与Session的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我知道技术上的差异。但是想得到它

澄清。给予一个机会是ViewState存储更有效率

基于会话。我没有需要在页面上共享信息的场景

跨页面但是有大量信息要缓存该页面。你可以

请告知哪个是有效的方法。该页面是一个搜索

函数,每天至少有10000个访问者。


问候

Vishwanathan

解决方案

Vishwanathan Raman写道:



问候
Vishwanathan




视频状态数据将通过互联网发送两次(从服务器

到浏览器,然后返回),因此您需要将其保持为小型

尽可能。此外,viewstate仅适用于回发场景,

如果你重定向或者你向用户提供了一些常规的

链接到你的某个页面,你将丢失它(但是这可能正是你想要的)


另一方面,如果你为很多会话存储大量数据,

你需要大量的内存在你的服务器上。加上会话状态

管理本身需要花费一些时间在服务器上。


我不认为有可能给出一个硬配方是否使用

viewstate或sessionstate,但如果你真的不需要会话,

你可以调查一个无会话的网站(< sessionState mode =" off" / >

在web.config中)使用viewstate来保持某种状态。


Hans Kesting


我发现某些对象的序列化成本和来自viewstate的
可能是非常可怕的。因此,如果数据是定制的

类,您可能需要对此进行测试。


将字符串填充到视图状态时我没有遇到同样的问题


当然,如果有很多数据并且你不能在内存会话中使用,

你需要序列化为状态服务器或SQL Server ...


Karl


-

我的ASP.Net教程
http://www.openmymind.net/ - 新增和改进(是的,弹出窗口很烦人)
http://www.openmymind。 net / faq.aspx - 非官方新闻组常见问题解答(更多内容

来了!)

" Josh" < s@a.com>在消息中写道

新闻:uw ************** @ TK2MSFTNGP14.phx.gbl ...

我找到了某些对象进入和从视图状态出来的序列化成本可能是可怕的。因此,如果数据是定制的类,你可能想测试一下。

将字符串填充到视图状态时我没有遇到同样的问题



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
Vishwanathan

解决方案

Vishwanathan Raman wrote:

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
Vishwanathan



The viewstate data will be sent twice over the internet (from server
to browser, and back), so you will want to keep that as small
as possible. Plus, viewstate will only work in postback-scenarios,
you will lose it if you redirect or you supply the user with a regular
link to some page of yours (but this might be exactly what you want)

On the other hand, if you store lots of data for lots of sessions,
you need a lot of memory on your server. Plus session-state
management itself costs some time on the server.

I don''t think it is possible to give a hard formula whether to use
viewstate or sessionstate, but if you really don''t need sessions,
you might investigate a session-less site (<sessionState mode="off"/>
in web.config) using viewstate to keep some state.

Hans Kesting


I''ve found that the serialisation costs of some objects going into and
coming out of viewstate can be horrendous. So if the data is in a bespoke
class you might want to test this.

I did not have the same problem when stuffing strings into the viewstate


Of course, if there''s a lot of data and you can''t use in memory sessions,
you''ll need to serialize it to state server or SQL Server...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Josh" <s@a.com> wrote in message
news:uw**************@TK2MSFTNGP14.phx.gbl...

I''ve found that the serialisation costs of some objects going into and
coming out of viewstate can be horrendous. So if the data is in a bespoke
class you might want to test this.

I did not have the same problem when stuffing strings into the viewstate



这篇关于ViewState与Session的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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