2012-08-03 3 views
0

다음과 같이 세션의 팝업 메시지를 만료시킨 코드가 있습니다. 그러나이 코드는 정확한 카운팅 세션을 수행 할 수 없습니다. 프로그램을 실행하면 설정 한 시간을 따르지 않은 세션 만료 메시지가 팝업으로 표시됩니다. 내가 알고있는 나의 메시지는 일찍 팝업 이유 때문에 내내 코드에 대해 올바른 세션 만료를 설정하는 방법은 무엇입니까?

Page.ClientScript.RegisterStartupScript(cstype, csname, strconfirm, false); 
이 내가 원하는대로 실행되지 않습니다,하지만 어떻게 추가 할 수 있도록 나는 "시간 제한"에 추가하지 않은

? 추가하려고하면 입력 형식 오류가 발생합니다. 누군가이 문제를 도와 줄 수 있습니까?

string csname = "timeoutWarning"; 
Type cstype = this.GetType(); 
if (!Page.ClientScript.IsStartupScriptRegistered(cstype, csname)) 
{ 
    var timeout = HttpContext.Current.Session.Timeout * 60 * 1000; 
    string strconfirm = "<script>if(!window.confirm('Your login session is about to expire. Do you want to extend it?')){window.location.href='../login.aspx'}</script>"; 
    Page.ClientScript.RegisterStartupScript(cstype, csname, strconfirm, false); 
} 

답변

0

시간 제한을 설정하는 곳이 없습니다. 가 작동 SessionTimeOutHandler() 말을하고 sesssion이 만료 동안 것을 호출하는 자바 스크립트 코드를 추출 :

string strconfirm = "<script>" + 
        "window.setTimeout('SessionTimeOutHandler()', 60000);" + 
"function SessionTimeOutHandler() { "+ 
" if(!window.confirm('Your login session is about to expire. Do you want to extend it?'))" 
+" {window.location.href='../login.aspx'}</script>"; }"; 

을 이제 당신의 strconfirm 초기화 문을 교체합니다. 그것은 당신을 위해 일해야합니다!

+0

해결책 덕분에 팝업 메시지가 어떻게 반복 될 수 있습니까? 만료 된 경우 표시 방법은 무엇입니까? 감사합니다. & 관해서 – user1539511

관련 문제