asp.net-core - ASP.NET Core IIS return DefaultAppPool instead of window user name
问题描述
I have used System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString(); to get window user name in development mode but when I deploy it to IIS, it returns DefaultAppPool instead of window user name. I have enabled both window authentication an anonymous authentication in development mode.
解决方案
WindowsIdentity.GetCurrent().Name
是线程运行的标识。
如果要获取window用户,请禁用匿名认证。
然后使用:
HttpContext.Current.User.Identity.Name;
推荐阅读
- python - Python从列表中提取第一个元素并清理字符串
- javascript - 停止 div 在浏览器调整大小时水平移动
- google-chrome - audio-context-constructor.js:8 AudioContext 不允许启动。它必须在页面上的用户手势后恢复(或创建)
- spring-cloud-stream - Spring cloud Stream Rabbit Binder,单一消息源,具有跨数据中心分布的云代工厂实例
- php - 如何在cakephp 3中的div data-setbg属性中显示图像
- reactjs - 单击输入框打开带有特定月份的月份选择器
- java - org.apache.http 缺少包,找不到 JAR
- google-cloud-platform - Cloud Datastore 中列表属性与多个属性与祖先键的权衡是什么?
- java - 如何从 Java 泛型类中提取类以满足编译器的要求?
- c# - MVC 如何将表单数据序列化为模型?