Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:42:48+00:00 2026-06-13T11:42:48+00:00

Is there a way to be notified when a user becomes logged in with

  • 0

Is there a way to be notified when a user becomes logged in with an ASP.net website?

Note: A user can become logged in without visiting a “login page”. If the “remember me” cookie exists, they can hit an arbitrary page and be logged in.

When a user is logged in i want to fetch some session related information.

Note: There is the Login.LoggedIn event. Problem is that that control doesn’t exist on every page; and the one page it is present on (Login.aspx) doesn’t call OnLoggedIn event.

In the same way that Global.asax has a global On Session Start notification:

void Session_Start(object sender, EventArgs e) 
{
}

i assume somewhere there’s a On User Logged In notifiation:

void LoggedIn(object sender, EventArgs e)
{
}

Bonus Reading

  • OnLoggedIn event on Login page ASP.NET
  • Run custom code on login
  • MDSN Logon.OnLoggedIn event
  • How to update last login date if “Remember Me” set?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:42:49+00:00Added an answer on June 13, 2026 at 11:42 am

    I think you don’t have a unique place to do that. In my case (MVC + log4net) I use this:

    • In Global.asax I check for authenticated users with pre-existing cookie.

      protected void Session_Start()
      {
          string ip = HttpContext.Current.Request.UserHostAddress;
      
          log.InfoFormat("Starting session: {0} from {1}.",Session.SessionID, ip);
      
          if ((HttpContext.Current != null) &&
              (HttpContext.Current.User != null) &&
              (HttpContext.Current.User.Identity.IsAuthenticated) )
          {
              string user = HttpContext.Current.User.Identity.Name;
              string type = "Cookie";
      
              log.InfoFormat("User {0} logged in with {1}.", user, type);
          }
      
      }
      
    • In my Account controller I check for local logins (I’m using Internet Application Template from MVC4, but you can do this in your Login.OnLoggedIn if you’re using Web forms)

      [HttpPost]
      [AllowAnonymous]
      [ValidateAntiForgeryToken]
      public ActionResult Login(LoginModel model, string returnUrl)
      {
          if (ModelState.IsValid && WebSecurity.Login(model.EMail, model.Password, persistCookie: model.RememberMe))
          {
              string user = model.EMail;
              string type = "Forms";
      
              log.InfoFormat("User {0} logged in with {1}.", user, type);
      
              return RedirectToLocal(returnUrl);
          }
      
          // If we got this far, something failed, redisplay form
          ModelState.AddModelError("", "The user name or password provided is incorrect.");
          log.ErrorFormat("Bad password or user name. User={0}", model.EMail, model.Password);
          return View(model);
      }
      
    • But I need to check for OAuth logins too, like this:

      [AllowAnonymous]
      public ActionResult ExternalLoginCallback(string returnUrl)
      {
          AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
          if (!result.IsSuccessful)
          {
              log.Debug("External login failure.");
      
              return RedirectToAction("ExternalLoginFailure");
          }
      
          if (OAuthWebSecurity.Login(result.Provider, result.ProviderUserId, createPersistentCookie: false))
          {
              log.InfoFormat("User {0} logged in with External {1} login. External UserID = {2}",
                  Membership.GetUser(OAuthWebSecurity.GetUserName(result.Provider, result.ProviderUserId)).UserName,
                  result.Provider,
                  result.ProviderUserId);
      
              return RedirectToLocal(returnUrl);
          }
      
          ...
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can get notified when a user closes a QMdiSubWindow?
Is there an easy way to get notified when user presses Power Off button
Is there a way I can be notified when a curl request completes? I'd
Is there a way to be notified when the content of the clipboard changes?
is there any way to be notified when a person calls or I call
Given an object, is there any way to get notified of when that object
Is there a way for a parent MenuItem to be notified when a child
Is there a way for a shared library to be notified when it is
Is there any way to be notified by windows OS when a new connection
is there a way to be notified when a program is executed or terminated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.