[英]HttpContext.Current.User.Identity.Name returns DefaultAppPool, why?
I'm trying to get the current user's Windows login but it just returns DefaultAppPool (the pool running the website). 我正在尝试获取当前用户的Windows登录名,但它只返回DefaultAppPool(运行网站的池)。 If I try and add impersonate in the web.config, I get the Windows user that runs IIS. 如果尝试在web.config中添加模拟,则将得到运行IIS的Windows用户。
IIS configuration has Windows authentication enabled and anonymous authentication disabled. IIS配置启用了Windows身份验证,并且禁用了匿名身份验证。
How do I get the user, that's visiting the website, instead? 我如何获取正在访问网站的用户呢?
string userName1 = HttpContext.Current.Request.LogonUserIdentity.Name;
string userName2 = User.Identity.Name;// don't take it from HttpContext
Check which one of this you need. 检查您需要哪一个。 Second one is property of the page ! 第二个是页面的属性!
The problem was that extra Windows IDs were stored in the Credential Manager making our PC look like the server's user was logged in. 问题在于,凭据管理器中存储了额外的Windows ID,使我们的PC看起来像服务器用户已登录。
My original code worked, it just didn't seem like it had been. 我的原始代码可以正常工作,但看起来似乎不是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.