ASP.Net Httpcontext.Current.User显示谁催生了线程最后一个用户 [英] ASP.Net Httpcontext.Current.User shows last user who spawned thread

查看:166
本文介绍了ASP.Net Httpcontext.Current.User显示谁催生了线程最后一个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很奇怪的问题,我现在面临与ASP.Net和当前用户。

使用ASP.Net 4.0。

由于某些原因,HttpContext.Current.User.Identity.Name报告用户身份作为谁打服务器的最后一个人。换句话说,它在某种程度上,由于某种原因缓存身份。

继承人的情景:
登录计算机1上用我自己的用户名,它显示的罚款。
登录计算机2,使用其他用户的,它显示的罚款。

在电脑1刷新浏览器,它显示了计算机2凭据!

我试过刚才的一切!我有我关闭,想尽可能设置一个自定义的角色提供。目前,我有我的web配置两行应该只是罚款。


我检查IIS中的以下内容:
匿名被禁用
Windows正在启用
禁用会话状态!

要测试的用户名,我这样做是:

  lblUserName.Text = HttpContext.Current.User.Identity.Name;

任何想法,我做错了什么?
难道这是因为我使用NTLM和不支持Kerberos?

任何帮助将是非常美联社preciated


解决方案

圣抽烟,多么愚蠢的问题!我发现通过翻录分开web.config中的答案。

原来缓存是问题。我有以下为我的web.config启用:


 <缓存启用=false的>
  <型材>
    <加上持续时间=72:00:00位置=客户延长=策略=CacheUntilChangekernelCachePolicy =CacheUntilChange/&GT的aspx。
    <加上持续时间=72:00:00位置=客户延长=策略=CacheUntilChangekernelCachePolicy =CacheUntilChange/&GTAXD。
    <加上持续时间=72:00:00位置=客户延长=策略=CacheUntilChangekernelCachePolicy =CacheUntilChange/&GTJS;
    <加上持续时间=72:00:00位置=客户延长=策略=CacheUntilChangekernelCachePolicy =CacheUntilChange/&GT的CSS。
    <加上持续时间=72:00:00位置=客户延长=策略=CacheUntilChangekernelCachePolicy =CacheUntilChange/&GTPNG;
    <加上持续时间=72:00:00位置=客户延长=策略=CacheUntilChangekernelCachePolicy =CacheUntilChange/&GTJPG;
    <加上持续时间=72:00:00位置=客户延长=策略=CacheUntilChangekernelCachePolicy =CacheUntilChange/&GTGIF;
  < /型材>
< /缓存>


禁用缓存固定它!
真是个奇怪的问题。

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

解决方案

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 :

<caching enabled="false">
  <profiles>
    <add duration="72:00:00" location="Client" extension=".aspx" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
    <add duration="72:00:00" location="Client" extension=".axd" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
    <add duration="72:00:00" location="Client" extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
    <add duration="72:00:00" location="Client" extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
    <add duration="72:00:00" location="Client" extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
    <add duration="72:00:00" location="Client" extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
    <add duration="72:00:00" location="Client" extension=".gif" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
  </profiles>
</caching>

Disabling caching fixed it! What a strange issue.

这篇关于ASP.Net Httpcontext.Current.User显示谁催生了线程最后一个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆