views:

401

answers:

3

I have an ASP.Net 3.0 SP1 app that uses Form Authentication.

While testing, I noticed that if I viewed a page that another user was viewing, the other users name would be displayed in the control on my master page. The Context.User.Identity is also for the other user.

If I switch to different page that no one else is viewing the Context.User.Identity is correct.

I stumped and would appreciate suggestions.
Thanks in advance.
Chris

+1  A: 

Make sure you are not using a link that comes with the authentication ticket when using a cookieless browser.

Also make sure to review any other that might be sharing the data among requests. Just like DOK said, but remember Application isn't the only way you could be doing that.

eglasius
+2  A: 

Maybe because output caching is enabled for the page: if the page is cached server-side with VaryByParam=none, all users will get the same copy from the cache.

I can only think of two things that can cause this:

  • You're storing user-specific data in a place shared between requests (e.g. in a static(C#)/shared(VB) variable, in the ASP.NET Cache, in the Application object, ...)

  • You have output caching enabled.

Check for:

  • OutputCache directives in your aspx and ascx files,

  • system.web/caching element in your web.config file(s),

  • Calls to the HttpCacheability.SetCacheability method.

If you can't find the problem:

  • Try creating a simplified version of your application until you get the simplest possible version that still reproduces the undesirable behaviour.

  • During this process of simplification you'll likely discover the problem for yourself. If not, post some code from the simplified version.

Joe
I not aware of any output caching, and VaryByParam is not in the solution.
cvoeller
Thanks for your help! After reading up on it; the symptoms should have pointed to the output cache. However I did take your advice and create a simple website, which worked fine, but the simple version helped me break down the problem.
cvoeller
A: 

It looks like the issue was caused because I setting targetframe="_self" or Target="_self". I removed all these and everything seem to be working fine.

One other note: If I were to refresh the page it would also display the page with the correct user.

cvoeller