如何获取我的asp.net项目中登录用户的名称 [英] how to get the name of the user loggedin in my asp.net project

查看:72
本文介绍了如何获取我的asp.net项目中登录用户的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

登录后我的asp.net项目登录页面如何获取当前用户登录的名称





假设如果你有一个library_add.aspx页面,并且要添加

页面,你必须登录页面,登录login.aspx后你还原到library_add.aspx然后在library_add.aspx.cs你这里想知道如果登录用户是管理员,我该怎么办?

how to get the name of the current user loggedin
in my asp.net project login page after logging in

suppose if you have a library_add.aspx page and for adding the
page you must have to login the page and after logging in to login.aspx you revert to library_add.aspx then here in library_add.aspx.cs you want to chck that if the login user is admin or not how can i do it?

推荐答案

lblerror.Text = Session["UserName"];





这就是你如何从Session中检索价值。虽然,你通常要检查以确保它不是空的。但在你的情况下,如果它为null,则不应该登录。



That''s how you can retrieve the value from the Session. Although, you''ll generally want to check to make sure it is not null first. But in your case, if it is null they shouldn''t be logged in.


这篇关于如何获取我的asp.net项目中登录用户的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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