.NET Application_BeginRequest - How to get User reference?
问题 I'm trying to get a reference to the user object in my Global.asax file's Application_BeginRequest . I'm using the property Context.User but I get a NullReferenceException . Is it possible to get a user object reference in Application_BeginRequest? 回答1: You don't have access to the User object because the request hasn't yet been authenticated. Try using Application_AuthenticateRequest instead. Here is an explanation of all Global.asax events: https://web.archive.org/web/1/http://articles