简体   繁体   中英

How to check Windows session from a web page?

I want my web page to perform an action every time the user Locks (Logoff) or Unlocks (Logon) the Windows session. If I'm able to recurrently call a JS code that checks the session status and do something based on the result, that would work too.

I got the first option to work with C#:

SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch);

static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
   if (e.Reason == SessionSwitchReason.SessionLock)
   {
      // Do something
   {
}

Unfortunately, through this method I'm only able to perform an action on my C# program and not on a web page.

Any idea of how I could achieve one of the following?

  • Trigger a JS function within a specific web page from the C# program above.
  • Check the Windows session from the web page itself.

EDIT: Please note I'm talking about the Windows (OS) session, not the browser window session.

I created a Windows Service which registers the Windows session in a file, then I am reading the file from the web page. Problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM