How do I get the current username in .NET using C#?

后端 未结 18 1843
忘了有多久
忘了有多久 2020-11-22 09:59

How do I get the current username in .NET using C#?

18条回答
  •  梦谈多话
    2020-11-22 10:04

    I tried several combinations from existing answers, but they were giving me

    DefaultAppPool
    IIS APPPOOL
    IIS APPPOOL\DefaultAppPool
    

    I ended up using

    string vUserName = User.Identity.Name;
    

    Which gave me the actual users domain username only.

提交回复
热议问题