2012-02-17 2 views
0

세션 상태가 "InProc"인 asp.net 웹 응용 프로그램이 있습니다. Inproc의 경우 기본적으로 세션 만료는 20 분입니다. 세션 만료 전에 1 분 동안 세션 만료 카운트 다운 팝업을 표시하고 싶습니다. 그러나 나는 많은 mimutes가 사라 졌다고 말하는 재산을 찾을 수 없다. 19 분인지 알 수있는 방법. 는 지금은 다음과 같은 일을 오전 :asp.net의 세션 타이머

if (Context.Session != null)// Check whether the session is null 
      { 
       if (Session.IsNewSession)// If the session is null, check whether the session is new 
       { 
       Response.Redirect("../SessionTimeout.aspx");//Redirect to time out page 
       } 
      } 
+2

그것은 유휴 시간 제한,의 여기에 가능한 솔루션입니다. 클라이언트에서이 작업을 수행해야합니다 (예 : 자바 스크립트. http://stackoverflow.com/questions/1470407/get-asp-net-session-last-access-time-or-time-to-timeout – StuartLC

+0

인증 티켓을 사용하는 경우 FormsAuthenticationTicket.Expiration 속성 (DateTime)은 다음과 같습니다. 유능한. http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.expiration.aspx를 참조하십시오. –

답변

0

당신이 이러한 목표를 달성하기 위해 몇 가지 아약스를 사용할 수 있습니다.

<script type="text/javascript"> 

    function checkAuthenticated() { 
     { 
      $.ajax({ 
       type: "POST", 
       url: "CheckAutheticated.asmx/checkAuthenticated", 
       data: "{}", 
       contentType: "application/json; charset=utf-8", 
       dataType: "json", 
       success: checkAuthenticatedOk, 
       error: checkAuthenticatedError 
      }); 
     } 
    } 
    function checkAuthenticatedOk() { } 
    function checkAuthenticatedError() { 
     $("#sessionExpiredCover").show(); 
    } 
    </script> 
    <style type="text/css"> 
    #sessionExpiredCover { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: 100000; 
    display: none; 
    background-color: #fff; 
    /*opacity: .7; 
    filter:progid:DXImageTransform.Microsoft.BasicImage(opacity=.7);*/ 
    } 
    </style> 

<div id="sessionExpiredCover"> 
    <div style="background-color:#fff; margin:100px; height:200px; width:400px;"><h1>Session expired</h1> 
     <br /> 
     <asp:HyperLink NavigateUrl="~/Login.aspx" runat="server" Text="Please log in again" /> 
    </div> 
</div> 

은 당신이의 WebMethod에 카운트 다운 코드를 개발해야합니다 : 당신의 서버 코드가 실행되는 경우 리셋 있도록

<%@ WebService Language="C#" Class="CheckAutheticated" %> 

using System; 
using System.Web; 
using System.Web.Services; 
using System.Web.Services.Protocols; 

[WebService(Namespace = "http://tempuri.org/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment  the following line. 
[System.Web.Script.Services.ScriptService] 
public class CheckAutheticated : System.Web.Services.WebService { 

[WebMethod] 
public string checkAuthenticated() 
{ 
    //your countDownCode 
    return "authenticated"; 
} 

}