1
내가 웹 응용 프로그램 및 페이지의 세션 시간 제한 및 사용자 상호 작용이이 집에 리디렉션 할 필요가있다

asp.net은 홈 페이지

에서 발견

솔루션/방문 페이지로 리디렉션 1) 응용 프로그램의 모든 aspx 페이지의 page_load에서 세션 확인. Global.asax에의 세션 시작에 2) 코드 나는 두번째 옵션에 갈거야

public void Session_Start  
{ 
     Response.Redirect("home.aspx"); 
     // or Server.Transfer("home.aspx"); 
} 

이 알려 1) 내가 올바른 방법 또는 이것에 대한 더 나은 솔루션입니다 있는지? Response.Redirect를 또는 Server.Transfer를

의 사용 여부를 두 번째 옵션에서 2)

고마워요

답변

2

왜 당신은 자바 스크립트를 어떻게 사용하지? 당신은 3000 세션 시간 제한되는 페이지 헤더에 JS 위의 코드 블록을 넣어

<script type="text/javascript"> 
setTimeout('window.location = "home.aspx"', 3000); 
</script> 

같은 setTimeout 방법을 사용할 수 있습니다.

+0

수있는 압정을하시기 바랍니다 것입니다 두 번째 솔루션에 비해 이점을 알려주십시오 (필자는 언급 했음). 둘째, global.asax 파일의 코드 줄. – Yogesh

5
내가 처음 갈 것 세션을 확인 할

..... 마스터 페이지의하는 OnInit 방법에

쓰기 다음 코드는 당신에게 쉽게

/// <summary> 
    /// Check for the session time out 
    /// </summary> 
    /// <param name="e"></param> 
    protected override void OnInit(EventArgs e) 
    { 
     base.OnInit(e); 
     if (Context.Session != null) 
     { 
      //check whether a new session was generated 
      if (Session.IsNewSession) 
      { 
       //check whether a cookies had already been associated with this request 
       HttpCookie sessionCookie = Request.Cookies["ASP.NET_SessionId"]; 
       if (sessionCookie != null) 
       { 
        string sessionValue = sessionCookie.Value; 
        if (!string.IsNullOrEmpty(sessionValue)) 
        { 
         // we have session timeout condition! 
         Response.Redirect("Home.aps"); 
        } 
       } 
      } 
     } 
    }