2014-04-03 23 views
0

使用更新面板時,我在刷新服務器會話時出現問題。我有三個按鈕,觸發器。使用Ajax UpdatePanel時刷新服務器端會話

<asp:UpdatePanel ID="TrackingUpdatePaenl" runat="server"> 
     <Triggers> 
      <asp:AsyncPostBackTrigger ControlID="btnPopulate" EventName="Click" /> 
      <asp:AsyncPostBackTrigger ControlID="btnGo" EventName="Click" /> 
      <asp:AsyncPostBackTrigger ControlID="btnTopUpdate" EventName="Click" /> 
     </Triggers> 
     <ContentTemplate> 
      //GridView that is updated by the triggers 

     </ContentTemplate> 
</asp:UpdatePanel> 

我遇到的問題是ServerState會話不會在異步回發後自行刷新。在我的webconfig中,我有會話狀態和表單驗證全部設置爲60分鐘超時。所發生的事情是,即使頁面處於活動狀態,頁面也會在60分鐘後由於不活動而超時。我使用這個JavaScript重定向用戶一旦他們的服務器端的會話超時......

if (HttpContext.Current.User.Identity.IsAuthenticated) 
{ 
    // Handle the session timeout 
    string sessionExpiredUrl = Request.Url.GetLeftPart(UriPartial.Authority) + "/DealLog/Account/SessionExpiredRedirect.aspx"; 
    StringBuilder script = new StringBuilder(); 
    script.Append("function expireSession(){ \n"); 
    script.Append(string.Format(" window.location = '{0}';\n", sessionExpiredUrl)); 
    script.Append("} \n"); 
    script.Append(string.Format("setTimeout('expireSession()', {0}); \n", this.Session.Timeout * 60000)); // Convert minutes to milliseconds 
    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "expirescript", script.ToString(), true); 
} 

上面的代碼是在我的網站主的頁面加載。這在沒有使用更新面板時效果很好。

用戶抱怨說,即使他們正在使用該頁面,它也會在60分鐘後超時。我在解決這個問題的印象是使用JavaScript來更新會話。我在互聯網上找到的所有東西都使用javascript來做到這一點,但是他們通過定時器調用服務器,即使頁面處於非活動狀態,頁面也會保持活動狀態。這不是我需要的解決方案。如何在點擊這些按鈕時刷新服務器會話?一旦用戶點擊按鈕,調用JavaScript調用另一個aspx頁面來保持會話活着?

我曾嘗試聯繫herehere,但我曾與其中任一沒有運氣。任何幫助是極大的讚賞。

回答

0

你沒有指定你正在使用的是哪個服務器操作系統,但可能是在特定時間間隔後應用程序池正在回收。

IIS 7 App Pool Advanced Settings

+0

是的,對不起,我忘了提及這一點。我正在使用Windows Server 2008.我已經檢查過該設置,並將其設置爲默認設置,如上所示。對於臨時修復,我刪除了更新面板和觸發器,但尚未正確執行。謝謝你的想法。 – Humpy