Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检查代码如何识别运行应用程序的用户,我想确保应用我在 IIS 中定义的域用户
谢谢
我以前用过这个,试试看是否适合你
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
您需要:HttpContext.Current.User或从控制器访问 HTTP 上下文。