Mukesh

Mukesh

  • NA
  • 228
  • 40k

Pop up time showing wrong

Jun 1 2021 7:05 AM
Hi i am trying to open popup session expire before 15 min but when i set 120 min in webconfig then minutes is showing wrong minutes
 
so please help me
 
What I have tried:
  1. $(function () {  
  2. $("#dialog").dialog({  
  3. autoOpen: false,  
  4. modal: true,  
  5. title: "Session Expiration Warning",  
  6. buttons: {  
  7. "Extend Session"function () {  
  8. ResetSession();  
  9. },  
  10. Logout: function () {  
  11. CloseSession();  
  12. },  
  13. Close: function () {  
  14. $(this).dialog('close');  
  15. }  
  16. }  
  17. });  
  18. });  
  19. function SessionExpireAlert(timeout) {  
  20. var minutes = timeout / 1000/60-1;  
  21. var seconds = 59;  
  22. $('#seconds').html(minutes + ':' + seconds);  
  23. var interval = setInterval(function () {  
  24.   
  25. //var timer2 = $("14:59");  
  26. //var timer = timer2.split(':');  
  27. //by parsing integer, I avoid all extra string processing  
  28. //var minutes = 14;  
  29. //var seconds = 59;  
  30. --seconds;  
  31. minutes = (seconds < 0) ? --minutes : minutes;  
  32. if (minutes < 0) clearInterval(interval);  
  33. seconds = (seconds < 0) ? 59 : seconds;  
  34. seconds = (seconds < 10) ? '0' + seconds : seconds;  
  35. $('#seconds').html(minutes + ':' + seconds);  
  36. }, 1000);  
  37. setTimeout(function () {  
  38. //Show Popup before 900 seconds of timeout.//  
  39. $('#dialog').dialog('open');  
  40. }, timeout - 900 * 1000);  
  41. setTimeout(function () {  
  42. window.location.href = "../../../User/SessionExpired";  
  43. }, timeout);  
  44. };  
  45. function ResetSession() {  
  46. //Redirect to refresh Session.  
  47. window.location = window.location.href;  
  48. };  
  49. function CloseSession() {  
  50. //Redirect to refresh Session.//  
  51. window.location.href = "../../../User/SessionExpired";  
  52. };  
  1. Response.Cache.SetCacheability(HttpCacheability.NoCache);  
  2. if (!this.IsPostBack)  
  3. {  
  4. Session["Reset"] = true;  
  5. Configuration config = WebConfigurationManager.OpenWebConfiguration("~/Web.Config");  
  6. SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState");  
  7. var timeout = section.Timeout.TotalMinutes * 1000 * 60;  
  8. ClientScript.RegisterStartupScript(this.GetType(), "SessionAlert""SessionExpireAlert(" + timeout + ");"true);  
  9. }  
  1. <sessionstate mode="InProc" timeout="120">  

Answers (3)