Mega Code Archive

 
Categories / ASP.Net Tutorial / Development
 

Log user in HttpModule

using System; using System.Web; using System.Diagnostics; public class LogUserModule : IHttpModule {   public void Init(HttpApplication httpApp)   {     httpApp.AuthenticateRequest += new EventHandler(OnAuthentication);   }   private void OnAuthentication(object sender, EventArgs a)   {     string name = HttpContext.Current.User.Identity.Name;     EventLog log = new EventLog();     log.Source = "Log User Module";     log.WriteEntry(name + " was authenticated.");   }   public void Dispose(){ } }