会话变量与HttpContext.Current.User [英] Session vars vs. HttpContext.Current.User

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

问题描述

目前,我正在存储在SQL中的会话变量中存储有关当前登录用户的信息

。但是,我使用

基于角色的安全性,所以我将自定义角色存储在我附加到Context.User的GenericPrincipal

对象中。我的问题是:


我可以创建一个新的类,例如ExtendedPrincipal,并且只需

继承System.Security.Principal并存储所有信息

目前存储在这个新对象的Session变量中?这是

负责/高效/合适吗?


提前致谢!

Jason

Currently, I am storing information about the currently logged on user
in Session variables that are stored in SQL. However, I am using
role-based security, so I am storing custom roles in a GenericPrincipal
object that I attached to Context.User. My question is this:

Can I create a new class, ExtendedPrincipal for instance, and simply
inherit System.Security.Principal and store all of the information
currently stored in Session variables in this new object? Is this
responsible/efficient/appropriate?

Thanks in advance!
Jason

推荐答案

由于Session特定于User,因此无需添加此b / b
级别的复杂性。


-

HTH,


Kevin Spencer

Microsoft MVP

..Net开发商

跟随者和贷款人都不是。


Jason < JA ************* @ hotmail.com>在消息中写道

news:11 ********************* @ l41g2000cwc.googlegro ups.com ...
Since the Session is specific to the User, there is no need to add this
level of complexity.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Jason" <ja*************@hotmail.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
目前,我正在存储在SQL中的Session变量中存储有关当前登录用户的信息。但是,我使用的是基于角色的安全性,因此我将自定义角色存储在我附加到Context.User的GenericPrincipal
对象中。我的问题是:

我可以创建一个新类,例如ExtendedPrincipal,并且只需继承System.Security.Principal并存储当前存储在Session中的所有信息这个新对象中的变量?这是否负责/有效/适当?

提前致谢!
Jason
Currently, I am storing information about the currently logged on user
in Session variables that are stored in SQL. However, I am using
role-based security, so I am storing custom roles in a GenericPrincipal
object that I attached to Context.User. My question is this:

Can I create a new class, ExtendedPrincipal for instance, and simply
inherit System.Security.Principal and store all of the information
currently stored in Session variables in this new object? Is this
responsible/efficient/appropriate?

Thanks in advance!
Jason



谢谢。我的印象是使用会话变量是/ b $ b昨天的技术,这个信息是通过新的.NET方式更好地处理的。这很好。现在我没有必要回去了。

做了很多改变。

Thanks. I was under the impression that using session variables was
yesterdays technology and that this information was handled better by a
new .NET way. This is good though. Now I don''t have to go back and
make alot of changes.


你可以做的事情虽然如此创建一个具有共享数字的类

将这些会话变量公开为属性。

这样你就可以获得强大的输入和intellisense这些值加上

不需要立即更改,因为引擎盖下仍然存储为

会话变量。


Patrice

-


" Jason" < JA ************* @ hotmail.com>一个écritdansle message de

news:11 ********************* @ o13g2000cwo.googlegro ups.com ...
Something you could do though would be to create a class with shared numbers
that exposes these session variables as properties.
This way you''ll get strong typing and intellisense on those values plus you
don''t need to change at once as under the hood there are still stored as
session variables.

Patrice

--

"Jason" <ja*************@hotmail.com> a écrit dans le message de
news:11*********************@o13g2000cwo.googlegro ups.com...
谢谢。我的印象是使用会话变量是昨天的技术,并且这种信息通过新的.NET方式得到了更好的处理。这很好。现在我不必回去做任何改变。
Thanks. I was under the impression that using session variables was
yesterdays technology and that this information was handled better by a
new .NET way. This is good though. Now I don''t have to go back and
make alot of changes.



这篇关于会话变量与HttpContext.Current.User的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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