ASP.NET传递多页会话之间的数据 [英] ASP.NET Passing Data Between Multiple Pages Session

查看:99
本文介绍了ASP.NET传递多页会话之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以似乎没有任何pretty回答如何通过多个页面间的数据的问题。已经做了一点功课后,这里的原因(或者至少是我搜集):


  1. ViewState的变量不跨网页使用。

  2. Session变量是不稳定的,必须谨慎使用。

  3. 饼干有潜在的安全问题,并采取时间和必须保持较小。

  4. 在URL存储瓦尔有限制的数据量,并且可以是不安全的。

  5. 在一个数据库临时存储方案商是一个真正的皮塔饼,因为你每可能被潜在地传递到另一个页面对象添加一个表。



    到目前为止,这是寻找像我将使用隐藏域到的keyid和独特的ID传递到下一个页面,然后检索数据库中的数据。你如何看待这一切的想法?什么是去这样做任何它的最佳方式?我在此应用程序的开发早,所以更改现在preferred。


编辑:我期待了很多使用该应用程序在任何一个时间的用户,这是否会影响我是否应该使用基于会话的SQL Server?
解决方案

Session变量应该能正常运行您的需求。

我会去的StateServer或SQLServer的会话状态模式。使用模式是InProc是最快的,但它有一些问题(包括所有用户会话,当一个新的二进制推,web.config中的变化等越来越下降)。会议是挥发性的,但你可以控制的波动性在几个方面。会议要求饼干,除非他们被配置为无Cookie(我强烈建议你保持它远离),但我认为这是一个合理的要求。

此外,您还可以创建从中创建可在会话变量存储对象结构或序列化类。结构或类将让你保持所有的数据在一个地方 - 你只能有一个会话变量担心

有将是优点和缺点任何方法,它是所有关于寻找的方式。我希望这有助于。

So there seems not be any pretty answer to the question of how pass data between multiple pages. After having done a little homework here's why (or at least what I've gleaned):

  1. ViewState variables don't persist across pages.
  2. Session variables are volatile and must be used sparingly.
  3. Cookies have potential safety issues and take time and must be kept small.
  4. Storing vars in the URL has limits to the amount of data and can be unsafe.
  5. Storing vars temporarily in a db is a real pita because you add one table per object that might be potentially passed to another page.

    So far it is looking like I will be using hidden fields to pass a keyid and unique id to the next page and then retrieve the data from the db. What are your thoughts on all of this? What is the best way to go about doing any of it? I am early in the development of this app, so making changes now is preferred.

edit: I am anticipating a lot of users using this application at any one time, does that affect whether or not I should be using SQL Server based Session?

解决方案

Session variables should work fine for your needs.

I would go with StateServer or SQLServer Session state mode. Using mode InProc is the fastest, but it has some issues (including all user sessions getting dropped when a new binary is pushed, web.config changes, etc). Sessions are volatile, but you can control the volatility in several ways. Sessions require cookies unless they are configured as cookieless (which I highly recommend you stay away from), but I think that is a reasonable requirement.

Also, you can create a struct or serializable class from which you create objects that you can store in a session variable. The struct or class will allow you to keep all of your data in one place - you only have one session variable to worry about.

There is going to be advantages and disadvantages for any method, it's all about finding the best method. I hope this helps.

这篇关于ASP.NET传递多页会话之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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