When I was writing a customer's B/S structure application, I suddenly found a trick. I don't know if it was a BUG in MS. I 'd like to give it to my friends who have studied it.
Originally, we considered writing a Session check class. After the Session fails, we must switch to the login page. Each page that calls this class can be stored in different WEB paths, therefore, the URLs for transferring to the login page are different. Each page must call and set the login page path, so the actual application will give up this idea.
Later, we thought it would be better to write a page to check that the Session is invalid. The client refresh the page every second and you can call it on a page. However, when we embed the ASPX through FRAME, requests are sent from time to time, not very nice, although the page is hidden.
Later, let's think about it. We just need to use a page, and use the refreshing technology to request the page with the expired Session. The refreshing technology here uses the xmlhttp object instead of the WEBService technology.
(Because the customer's BS system uses the FRAME framework, the top page displays the software name and user login information, so the call is placed on this page)
Let's take a look at the code, mainly the client's JavaScript script program.
<Script language = "javascript">
Var idx = 0;
Function ChkSession ()
{
Var Http = new ActiveXObject ("Microsoft. XMLHTTP ");
Http. open ("GET", "ChkSessionOut. aspx", false); // check the page where the Session fails.
Http. send ();
Var str = Http. responseText; // The returned result after ASPX is executed.
// Idx ++
// Document. all ("ConvertResult"). innerHTML = str + idx;
If (str = "notnull ")
{
// Alert (str );
}
Else
{