简体   繁体   English

@HttpContext.Current.User.Identity.Name 返回不同的用户名

[英]@HttpContext.Current.User.Identity.Name returns a different user name

I am working on a web application using azure active directory authentication hosted in azure. When I try to display the logged in user using "@HttpContext.Current.User.Identity.Name" it display the user email as expected.我正在使用托管在 azure 中的 azure 活动目录身份验证来处理 web 应用程序。当我尝试使用“@HttpContext.Current.User.Identity.Name”显示登录用户时,它会按预期显示用户 email。 But when some other user logs in at the same time, my UI displays the other user name.但是当其他用户同时登录时,我的 UI 会显示其他用户名。 I am not caching or using static variables to retrieve the logged in user information.我没有缓存或使用 static 变量来检索登录的用户信息。 I tried using the below but same issue exist.我尝试使用以下但存在同样的问题。 Any pointers on the issue to display correct logged in user name?关于显示正确登录用户名的问题的任何指示?

  1. @User.Identity.Name @User.Identity.Name
  2. @HttpContext.Current.User.Identity.Name @HttpContext.Current.User.Identity.Name

Short answer here... Let me know if it works for you too.在这里简短回答......让我知道它是否也适合你。

Sub CloseConn(ByVal sender As Object, ByVal e As EventArgs)    
    Request.Cookies.Clear()
    FormsAuthentication.SignOut()
    Session.Clear()
End Sub

Here's the control on my masterpage: MYMASTER.MASTER这是我的母版页上的控件:MYMASTER.MASTER

<asp:LoginStatus OnLoggedOut="ClearAllData" ID="LoginStatus1" runat="server" LogoutPageUrl="http://www.mysite1234.domain/" LogoutText="<%$Resources: Glossary, LogoutText%>" LoginText="" LogoutAction="Refresh" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HttpContext.Current.User.Identity.Name返回DefaultAppPool,为什么? - HttpContext.Current.User.Identity.Name returns DefaultAppPool, why? 模拟HttpContext.Current.User.Identity.Name - Mock HttpContext.Current.User.Identity.Name 更改HttpContext.Current.User.Identity.Name - Changing HttpContext.Current.User.Identity.Name 用户登录后更改HttpContext.Current.User.Identity.Name - Changing HttpContext.Current.User.Identity.Name after User is logged in HttpContext.Current.User.Identity.Name始终为null - HttpContext.Current.User.Identity.Name is always null 访问DbContext中的HttpContext.Current.User.Identity.Name - Accessing HttpContext.Current.User.Identity.Name in the DbContext HttpContext.Current.User.Identity.Name在.ashx处理程序中不起作用 - HttpContext.Current.User.Identity.Name not working in .ashx hander HttpContext.Current.User.Identity.Name无法转换 - HttpContext.Current.User.Identity.Name can't be converted HttpContext.Current.User.Identity.Name在Active Directory中的什么位置? - HttpContext.Current.User.Identity.Name where is it looking in Active directory? HttpContext.Current.User.Identity.Name 非 Windows 用户的替代方案? - HttpContext.Current.User.Identity.Name Alternative for Non-Windows User?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM