How to Make ASP. Net Program expire after closing the browser for one minute

Source: Internet
Author: User


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
{

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.