I have a .NET 4 application that I am taking to IIS 7.5. In it, I have the following code: HttpContext.Current.Request.ServerVariables["LOGON_USER"] This code is in my global.asax file and is in my Application_BeginRequest method.
For my application, this is returning an empty string. That makes me think that I don't have my authentication setup. I go into the IIS admin manager, and I have Anonymous, Digest, and Forms Authentication disabled. I have ASP.NET Impersonation, Basic, and Windows Authentication enabled.
Any ideas regarding what I need to do to get the actual windows auth userid wou开发者_如何学编程ld be appreciated.
Wally
Take a look at this page http://msdn.microsoft.com/en-us/library/ms178473.aspx (somewhere in the middle)
It explains which events are executed when a request comes in. BeginRequest is one of the first events that are raised when a request comes in and this means that not every piece of information you might need is available yet. In your case try capturing the PostAuthenticateRequest
and see if that works. Also, you might be interested in User.Identity.Name
.
精彩评论