How to get the current Windows user with ASP.NET Core RC2 MVC6 and IIS7

前端 未结 4 1315
难免孤独
难免孤独 2021-01-17 10:48

I have an intranet site built in MVC6 using ASP.NET Core RC2. I want to get the Windows username of the person accessing the intranet site.

So if Jim goes to the in

4条回答
  •  执笔经年
    2021-01-17 11:27

    Using var userId = this.User.Identity.Name; worked for me. My app is running on an intranet and all I was looking to do is get the user's login Id from Windows. I didn't need to store the user's information as that is already being stored in Active Directory.  

提交回复
热议问题