asp.net - HttpContext.Current.User.Identity.Name not right when simultaneous login from 2 machines -
i've got asp.net webserver iis 7.
my authentication code (forms authentication) follows on login page:
var isauthenticated = membership.validateuser(usernametextbox.text, passwordtextbox.text); if (isauthenticated) { formsauthentication.redirectfromloginpage(usernametextbox.text, true); } else { var customvalidator = new customvalidator(); customvalidator.isvalid = false; customvalidator.errormessage = getlocalresourceobject("loginfailed.errormessage").tostring(); customvalidator.validationgroup = "allvalidators"; page.validators.add(customvalidator); }
and on page display username:
if (httpcontext.current.user.identity != null && !string.isnullorempty(httpcontext.current.user.identity.name)) { string authenticatedusername = httpcontext.current.user.identity.name; return "authenticatedusername=" + authenticatedusername; } else { return null; }
my issue if me , 1 of colleagues login @ same time different login names (and different accounts), accounts set ok (we see different items) 1 of names set other logged in user.
so if login username foo
, colleague username bar
, both logged in our respective accounts either see user name bar
or see username foo
on page.
i've seen other accounts of strange behaviour of asp.net authentication , claimed fixed disabling output cache feature. didn't work me.
any appreciated, i've got no idea how track issue.
in end issue code. wanted disable caching page , used following
<%@ outputcache duration="1" nostore="true" varybyparam="none" %>
which seemed work , correct. wasn't complete though , full version
<%@ outputcache duration="1" nostore="true" location="none" varybyparam="none" %>
which works.
a posteriori it's obvious waht happened. although client won't store page, asp 1 second if location
isn't set none
.
the documentation on msdn confusing form me topic.
Comments
Post a Comment