[英]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. 我希望我的网页在用户每次锁定(注销)或解锁(登录)Windows会话时执行一项操作。 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. 如果我能够反复调用检查会话状态并根据结果执行某些操作的JS代码,那么它也将起作用。
I got the first option to work with C#: 我有第一个选择使用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. 不幸的是,通过这种方法,我只能对C#程序执行操作,而不能对网页执行操作。
Any idea of how I could achieve one of the following? 关于如何实现以下目的的任何想法?
EDIT: Please note I'm talking about the Windows (OS) session, not the browser window session. 编辑:请注意,我是在谈论Windows(OS)会话,而不是浏览器窗口会话。
I created a Windows Service which registers the Windows session in a file, then I am reading the file from the web page. 我创建了一个Windows服务,该服务将Windows会话注册到一个文件中,然后从网页上读取该文件。 Problem solved. 问题解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.