无法获取当前登录的用户名(ASP.Net) [英] Unable to get currently logged on username (ASP.Net)

查看:78
本文介绍了无法获取当前登录的用户名(ASP.Net)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我试图通过我的ASP.Net网页获取当前用户的用户名。我尝试添加Windows身份验证:



< authentication mode =   Windows /> 
< authorization>
< deny users = /> <! - 防止匿名授权 - >
< / 授权 >





然后我用这个字符串返回用户名:



  string  strUsername = System.Web.HttpContext.Current.User.Identity.Name; 





我的问题是,这应该返回用户名bgates,它返回TESTgates,其中TEST是我的域名,gate是用户的姓氏。有人能告诉我我做错了什么/如何解决这个问题?



谢谢!

解决方案

< blockquote>



参考



如何使用ASP.NET获取Window NT记录的用户名 [ ^ ]

Hello,

I am attempting to get the username of the current user through my ASP.Net webpage. I have attempted adding Windows Authentication:

 <authentication mode ="Windows" />
<authorization>
  <deny users="?"/> <!--Prevent Anonymous Authorization-->
</authorization>



I am then using this string to return the username:

string strUsername = System.Web.HttpContext.Current.User.Identity.Name;



My issue is that where this should be returning the username bgates it is returning TESTgates where TEST is my domain and gates is the user's last name. Is anyone able to tell me what I am doing wrong / how to fix this?

Thanks!

解决方案

Hi,

Refer

How to Get Window NT Logged User Name Using ASP.NET[^]


这篇关于无法获取当前登录的用户名(ASP.Net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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