为什么你会永远使用asp.net的ViewState存储对象在会话存储对象? [英] Why would you ever use asp.net's ViewState storage object over the Session storage object?

查看:271
本文介绍了为什么你会永远使用asp.net的ViewState存储对象在会话存储对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了因为会话存储会话全局的多个页面,为什么你想使用视图状态保存值?

Other than because session storage is session-global to more than one page, why would you ever want to use the viewstate to hold values?

这似乎很荒谬发送任何形式的比一些小的查询字符串值等信息,来回从客户机到服务器。我的意思是带宽(!)的浪费,只是存储的目的。这次会议,同时在多个页面全局的,好像到视图状态完全更好的选择。

It seems kind of ridiculous to send any kind of information other than a few small query string like values, back and forth from the client to server. I mean what a waste of bandwidth(!), simply for storage purposes. The session, while global across multiple pages, seems like a completely superior alternative to the viewstate.

特别是随着asp.net AJAX控件和变型,视图状态可能会迅速变得臃肿跟踪的各种状态和所有这些不同的控制变量和HTML元素。

Especially with asp.net ajax controls and variants, the viewstate could quickly become bloated tracking the various states and variables of all those different controls and html elements.

不过,为什么是有网页变量视图状态的存储,并在所有对象?

But then why is there viewstate storage for page variables and objects at all?

也许我缺少对页面的ViewState存储另一个伟大的使用情况,没有人知道的东西在那里?

Maybe I'm missing another great usage for the page's viewstate storage, does anyone know something out there?

感谢您阅读!

编辑:每个人都有一个伟大的回答,对不起,如果我不接你。

Everyone had a great answer, sorry if I didn't pick yours.

推荐答案

会话用完,视图状态不 - 你可以回去一个小时后,你的视图状态将仍然可用。视图状态也始终保持可用状态,当你去前进/后退的网站上,会话的变化。

Sessions run out, Viewstate does not - you can go back an hour later and your viewstate will still be available. Viewstate is also consistently available when you go back/forward on the website, Session changes.

这篇关于为什么你会永远使用asp.net的ViewState存储对象在会话存储对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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