ASP.Net Httpcontext.Current.User 显示最后一个生成线程的用户
我在 ASP.Net 和当前用户方面面临着非常奇怪的问题。
使用 ASP.Net 4.0。
由于某种原因,HttpContext.Current.User.Identity.Name 将用户身份报告为最后访问服务器的人。换句话说,它以某种方式并出于某种原因缓存了身份。
场景如下: 使用我自己的用户名登录计算机 1,显示正常。 用其他用户名登录计算机2,显示正常。
刷新计算机 1 上的浏览器,它会显示计算机 2 的凭据!
我已经尝试了几乎一切!我有一个自定义角色提供程序,我将其关闭并尝试了所有可能的设置。目前我的网络配置中有两行应该可以正常工作。
我在 IIS 中检查了以下内容: 匿名已禁用 Windows 已启用 禁用会话状态!
为了测试用户名,我这样做:
lblUserName.Text = HttpContext.Current.User.Identity.Name;
知道我做错了什么吗? 这可能是因为我使用的是 NTLM 而不是 Kerberos 吗?
任何帮助将不胜感激
Very strange issue I'm facing with ASP.Net and Current User.
Using ASP.Net 4.0.
For some reason, HttpContext.Current.User.Identity.Name reports the User Identity as the last person who hit the server. In other words, it somehow and for some reason caches the Identity.
Heres the scenario:
Log in on computer 1 with my own username and it shows fine.
Log in on computer 2 with other username and it shows fine.
Refresh Browser on Computer 1 and it shows computer 2 credentials!!!
I've tried just about everything! I had a custom role provider which I turned off and tried every possible setting. Currently I have two lines in my web config which should work just fine.
I've checked the following in IIS:
Anonymous is disabled
Windows is enabled
Disabled Session State!
To test the username, I'm doing this :
lblUserName.Text = HttpContext.Current.User.Identity.Name;
Any Idea what I'm doing wrong?
Could this be because i'm using NTLM and not Kerberos?
Any help would be much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
圣烟,多么愚蠢的问题啊!我通过分解 web.config 找到了答案。
事实证明缓存是问题所在。我在 web.config 中启用了以下内容:
禁用缓存修复了它!
多么奇怪的问题啊。
Holy Smokes, what a stupid issue! I found the answer by ripping apart the web.config.
Turns out caching was the issue. I had the following as enabled in my web.config :
Disabling caching fixed it!
What a strange issue.