如何从asp中的静态类获取经过身份验证的用户的用户名。净 [英] how do I get the username of authenticated user from a static class in asp. net

查看:73
本文介绍了如何从asp中的静态类获取经过身份验证的用户的用户名。净的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人帮助我如何从我的静态类中获取asp.net中经过身份验证的用户的用户名,以便我可以查询我的数据库非成员资格提供者,以便我可以从我的数据库中获取有关此类用户的其他信息。谢谢

解决方案

除非你真的非常需要,否则不要使用静态。



<但是,如果你必须:照常将Authenticated用户ID存储在Session中,那么在静态方法中使用静态上下文:

  object  userID = HttpContext.Current.Session [  UserID ]; 


please can somebody help with how to get the username of authenticated user in asp.net from my static class so that I can query my database that non membership provider one so dat I can fetch additional information about such user from my database. Thanks

解决方案

By preference, don't use static unless you really, really have to.


But, if you have to: store the Authenticated user id in the Session as usual, then in your static method use the static context:

object userID = HttpContext.Current.Session["UserID"];


这篇关于如何从asp中的静态类获取经过身份验证的用户的用户名。净的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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