ASP.Net会话管理 [英] ASP.Net Session Management

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

问题描述



我是ASP.Net的新手.
我创建了一个具有多个用户的Web应用程序.
用户在运行时保存数据,这些数据在会话中维护,但是不同用户的数据会合并并显示给所有用户.

例如:用户在文本框中输入数据,然后单击添加按钮将其转到网格.随着所有用户开始添加,所有用户的数据将合并到网格中.

我也不知道如何使用global.asax.

我尝试寻求帮助,但找不到任何具体的内容.

请任何人可以帮助我通过会话ID维护会话.

Hi,

I am new to ASP.Net.
I have created a Web Application which has multiple users.
Users save data at run time which is maintained in sessions, but the data of different users get combined and displays to all users.

For example: Users enters data in text boxes and on add button click it goes to grid. The data of all users get combined in grid as all users start adding.

I also do not know how to use global.asax.

I tried to serach for help, but can''t find anything specific.

Please any one can help me to maintain session by session ID.

推荐答案

看看这个

在ASP.Net中浏览会话 [
Take a look at this

Exploring Session in ASP.Net[^]


我认为您需要对处理Asp.net中>. [ http://www.asp.net/general/videos/lesson -4-understanding-web-application-state [
I think you need to have a clear understanding of handling Sessions in Asp.net, before starting implementation. This[^] may be a good resource for you to start with.

However, let me try to help you a bit

As you said, users will save data and the data will be saved into the Session. But, as each user have their own session, a particular user''s data will not be available to another user''s data.

So, either you have to save the data in the Database, or, if you don''t do that for some reason, you have to save user''s data in Application state or Cache.

Application or Cache is not user specific, rather, they are global to all users. So, if all users save their data to either Application, or, Cache, the combined data will be the same for all users.

You can see http://www.asp.net/general/videos/lesson-4-understanding-web-application-state[^] to learn about Application state.

Best of luck.


戴夫,
让我知道一件事-您是从数据库还是从Session数据绑定网格?根据我对您的问题的理解,您正在将数据保存在Session中以及数据库中,这就是为什么单击添加"按钮后数据对所有用户合并并在网格中对所有用户可见的原因.无论如何,我都会针对您的问题提供两种解决方案:

第一个解决方案:-

1.将运行时数据添加到集合对象中,例如列表或数组.
2.从此收集对象绑定网格.
3.使用密钥将此收集对象存储在会话中.
4.对于每个添加项,请执行步骤1-3.

第二种解决方案:-

1.在数据库表中添加UserID列,以按用户标识数据.
2.现在,您可以从该表中获取给定用户的数据.
Hi Dave,
Let me know one thing- are you binding your grid from database or from Session data? As per my understanding about your question, you are saving data in Session as well as in database and that''s why data after clicking Add button get combined for all users and visible to all users in the grid. Any way I''ve two solutions regarding your problem:

First Solution:-

1. Add your run time data in a collection object e.g. List or Array.
2. Bind your grid from this collection object.
3. Store this collection object in the Session using a key.
4. Follow steps 1-3 for each addition.

Second Solution:-

1. Add UserID column in your database table to identify data as per user.
2. Now you can fetch data from this table for a given user.


这篇关于ASP.Net会话管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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