如何在ASP.NET中存储会话数据? [英] How can I store session data in ASP.NET?

查看:23
本文介绍了如何在ASP.NET中存储会话数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个可与ASP.NET一起使用的flex应用程序.(通过weborb).而且,我们在.NET端使用多个数据来加载数据,例如:UserId,ChannelId,...目前,只有userid存储在HttpContext.Current.Identity的名称中.因此flex端不需要一直推送用户ID,但是现在我们也想禁用channelid的推送".

We have a flex application that works with ASP.NET. (through weborb). And we use several data at the .NET Side to load data, ex: UserId, ChannelId, ... For now only userid is stored in the name of the HttpContext.Current.Identity. So the flex side doesn't need to push the user id all the time, but now we want to disable the "push" of the channelid too.

我想知道我们应该在哪里存储"这些数据.会话是否足够保存,还是需要使用Cookie?或还有其他解决此问题"的方法.

I was wondering where we should "store" these data. Is a Session save enough or do we need to use a cookie? or are there any other methods for this "problem".

推荐答案

我建议使用 Session ,因为这些值随后存储在服务器上(cookies存储在客户端上).还可以使用静态类并将会话包装在那里.

I'd recommend to use Session because the values are then stored on the server (cookies are stored on the client). Also use a static class and wrap the session there.

代替

Session["channelid"] = ChannelId

使用

SessionManager.ChannelId = ChannelId

,您可以将 SessionManager 声明为具有使用该会话的静态属性的静态类.我相信这也是Microsoft的普遍做法.

and you can declare SessionManager as a static class with static properties that use the session. I believe this is a general Microsoft practice as well.

欢呼

这篇关于如何在ASP.NET中存储会话数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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