Get Windows Username in ASP.NET without System.Web

喜夏-厌秋 提交于 2019-12-02 02:32:50

Maybe you can use the CurrentPrincipal property of the Thread class:

using System.Threading;

string userName = Thread.CurrentPrincipal.Identity.Name;

You can use Environment.UserName which lives in System.

System.Web namespace is definitely available in an ASP.Net application. You can definitely make use of it. Apart from that, you will also have the Membership providers that you can use to validate or tell the current user name.

Using System.net -- NetworkCredential.Username?

Ref: http://msdn.microsoft.com/en-us/library/system.net.networkcredential.username.aspx

If Windows authentication is on this might work: Page.User.Identity.Name In my case, it does.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!