vdesai_8
asked on
javascript - capture user inactivity
We have an ASP.Net/ VB.Net web application. If the user is inactive for 5 minutes(no keystroke or mouse movement) then the user should be asked for a password again to continue using the application.
I think I can do it through javascript using a timer, but how can I have this javascript function be called from each aspx page? I think its not a good idea to copy and paste the javascript function on each aspx page. Is there a global place where I can place the javascript code & call it from each aspx page?
Please advise. Thanks in advance.
I think I can do it through javascript using a timer, but how can I have this javascript function be called from each aspx page? I think its not a good idea to copy and paste the javascript function on each aspx page. Is there a global place where I can place the javascript code & call it from each aspx page?
Please advise. Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A better solution would be to set the session timeout of your application as 5 minutes in your web.config
<configuration>
<system.web>
<sessionState mode="InProc" cookieless="false" timeout="5" />
.....
and your code in global.asax must check whether there is a active session and if not, redirect him to the page which will ask for the password ..
but if you have to use javascript and you want it be used in all the pages, then use a master page and every aspx page must have this page as the "master" file .. then you need to have the script statement mentioned above ONLY in one page and that is the master page ...
<script type="text/javascript" src="whatever.js"></script
this will save the effort of copying the script tag in all your aspx pages ..
Rejo