[英]How can I find the users windows login username from ASP.Net?
I have an ASP.Net web application running on an IIS server, and I need to find the visitors login username. 我有一个运行在IIS服务器上的ASP.Net Web应用程序,我需要找到访问者的登录用户名。
How can I can find this? 我怎么能找到这个? When testing locally it found my username using
new WindowsPrincipal(WindowsIdentity.GetCurrent());
在本地测试时,它使用
new WindowsPrincipal(WindowsIdentity.GetCurrent());
找到了我的用户名new WindowsPrincipal(WindowsIdentity.GetCurrent());
, but it finds NETWORK SERVICE when running the app on the server. ,但在服务器上运行该应用程序时会找到“ 网络服务 ”。
I assume you use forms authentication. 我假设您使用表单身份验证。 Try:
尝试:
User.Identity.Name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.