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.
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.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.