"DotNet Coder" <d0*********@yahoo.dot.com> wrote in message
news:Ol**************@TK2MSFTNGP15.phx.gbl...
Well, because, in the case of using ASP.NET, System.Environment.UserName
/System.Environment.UserDomainName will return the name of the currently
logged on user on the server. Not the client using your web application.
In winforms, I suppose you could use System.Environment with no problem.
IMO, OP wasn't asking about ASP.NET, anyway your answer is incorrect. An
empty or a bogus value will be returned by calling
System.Environment.UserName from within asp.net, the reason is that "aspnet"
has no associated profile (and as such no Environment block) as it is not an
interactive login. Even if asp.net run's with domain credentials or as an
interactive login it's profile isn't loaded and the Environment shouldn't be
trusted.
Note that in general calling System.Environment is only a valid option when
the caller is associated with a login that has it's profile loaded (an
interactive login), in all other cases it shouldn't be used.
Willy.