我可以通过 ajax 关闭监视器并获得响应吗?
我正在开发一个网络应用程序,该应用程序将在信息亭上运行并通过触摸屏界面使用。我们想要从管理页面关闭屏幕,因此使用 Windows 电源管理不是一个选项,因为必须明确关闭显示器。
按照这个问题中发布的建议,我能够对我的控制器进行 AJAX 调用,关闭显示器。但是,我的 AJAX 请求从未收到响应,因为 SendMessage() 之后的任何代码都没有执行,我不确定为什么。这超出了我使用 C# 的能力,所以这可能是我不理解的简单事情。 Firebug 显示请求挂起。我尝试单步执行,但是一旦调用 SendMessage(),就不会发生任何其他事情。我还尝试打开监视器(当它打开时),看看是否可以单步执行,但结果是相同的:在 SendMessage() 之后,没有其他任何执行。
那么可以通过 AJAX 来完成并接收响应吗?
I'm working on a web application that will run on a kiosk and used via a touch screen interface. We're wanting to turn off the screen from an administrative page, so using Windows power management isn't an option as turning off the monitor has to be explicitly done.
Following the suggestion posted in this question, I was able to make an AJAX call to my controller and turn the monitor off. However, my AJAX request never receives a response because any code after SendMessage() is not executed and I am unsure as to why. This is venturing beyond my abilities with C#, so it could be something simple that I do not understand. Firebug shows the request hanging. I tried stepping through, but once SendMessage() is called, nothing else happens. I also tried turning on the monitor (while it's on) to see if perhaps I could step through, but the result was the same: after SendMessage(), nothing else executes.
So it is possible to do it via AJAX and receive a response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您遵循使用
SendMessage(...)
方法的代码。如果您阅读该问题链接到的文章的底部(http://www.codeproject.com/KB/cs/Monitor_management_guide.aspx),它讨论了一些类似方法之间的行为差异:我认为如果您调用
PostMessage(...)
并传递相同的参数,您可能会得到您正在寻找的行为。I'm assuming you followed the code that uses the
SendMessage(...)
method. If you read the bottom of the article that was linked to from that question (http://www.codeproject.com/KB/cs/Monitor_management_guide.aspx), it talks about the difference in behavior between a few similar methods:I think if you call
PostMessage(...)
passing it the same arguments, you will probably get the behavior you're looking for.