什么是识别登录的用户的最佳方法是什么? [英] What is the best way to identify logged user?

查看:148
本文介绍了什么是识别登录的用户的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找有效的方式使用 asp.net 登录控制时,跟踪已登录用户

I was looking for the efficient way to track the logged users when using asp.net login control

        if (!IsPostBack)
        {
            if (Membership.GetUser() != null)
            {
                var user = Membership.GetUser();
                Session["user"] = user;
            }
            else
            {
                Session["user"] = "";
            }
        }

任何建议将AP preciated

Any suggestions will be appreciated

推荐答案

为什么这一切的痛苦,为什么你尝试将其保存在Session(这是特定的用户,而不是应用特定的),当你可以简单地得到它这个对象:

why all this pain and why do you try to save it in the Session (which is user specific and not application specific), when you can simply get it from this object:

HttpContext.Current.User

检查这一个细节:<一href=\"http://stackoverflow.com/questions/5417125/how-to-get-current-user-whos-accessing-asp-net-app\">How获得当前用户是谁在访问ASP.net应用程序?

这篇关于什么是识别登录的用户的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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