且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查用户是否在特定页面中.

更新时间:2023-11-29 08:50:34

在没有客户端启动某些操作的情况下,服务器无法直接调用客户端.想一想.许多站点收集有关连接到其站点的客户端的信息.您想让他们中的任何人随时连接到您的Web浏览器吗?

您将需要一种机制,该机制使客户端每隔一定的时间向服务器发送ping指示它们仍然连接.
There is no way for the server to call a client directly without some action being initiated by the client. Think about it. Many sites collect information about the clients who connect to their site. Would you want anyone of them to connect to your web browser at any time?

You will need a mechanism that has the client send a ping to the server at certain intervals to indicate they are still connected.


您可以使用在页面中更新的会话变量.加载方法.
You could use a session variable that''s updated in the Page Load method.


,但是保存游戏状态的应用程序在退出浏览器时将保持为true,因此会表示他不在游戏中时仍在游戏中.
如果我只能在session_end发生时获取会话值,那一切都会很好

我正在尝试使用此代码

but the application which saves the game status will stay true when he exits the browser so it will say he is still in the game while he isn''t!
if i could just get the session value when session_end happens everything would be great

I am trying to use this code

if (Application["player1"] == Session["mynick"])
{
    Application["status1"] = false;
    Application["player1"] = "";
}




在session_end中,但当sassion ["mynick"]没有值时:<</xml>




in the session_end but when it happens sassion["mynick"] has no value :<</xml>