Kurkula
Kurkula

Reputation: 6762

@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. But when some other user logs in at the same time, my UI displays the other user name. I am not caching or using static variables to retrieve the logged in user information. 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
  2. @HttpContext.Current.User.Identity.Name

Edit: After analysis, I found that the issue is using [Authorize] and [OutputCache] attributes together. There is some issues in terms of caching logged in users if both are used. Any clue how to resolve the issue?

Upvotes: -2

Views: 707

Answers (1)

StarrLorrdd
StarrLorrdd

Reputation: 1

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

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

Upvotes: 0

Related Questions