次の記事を使用して、要件に従っていくつかのカスタマイズを行い、asp.net mvc2 アプリケーションでセッション タイムアウトの警告メッセージを表示するように実装しました。
http://fairwaytech.com/2012/01/handling-session-timeout-gracefully/
次のセッション状態モードとともに:
<sessionState mode="SQLServer" sqlConnectionString="Data Source=StudentsDB;User ID=xxxxxxx;Password=xxxxxxx;Integrated Security=False;MultipleActiveResultSets=True" allowCustomSqlDatabase="true" cookieless="false" timeout="30" compressionEnabled="true" sqlCommandTimeout="240" />
Forms timeout=15 および Sessiontimeout = 30
アプリケーションは、私の開発環境と開発統合環境で正常に動作しています (両方の環境にロードバランサーがありません。
F5 ロードバランサー構成が利用可能な QA およびステージング環境にアプリケーションをデプロイすると、動作がおかしくなり始めました。
アラート ポップアップが表示されるユーザーもいれば、まったく表示されないユーザーや、自動的にログアウトするユーザーもいます。
機能が正しく実行されておらず、奇妙な動作をしています。
F5 ロードバランサで有効なスティッキー セッションはありません。
Global.asax.cs ファイルには、次のコードがあります。
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
Only access session state if it is available
if (Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState)
{
//If we are authenticated AND we don't have a session here.. redirect to login page.
HttpCookie authenticationCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authenticationCookie != null)
{
FormsAuthenticationTicket authenticationTicket = FormsAuthentication.Decrypt(authenticationCookie.Value);
if (!authenticationTicket.Expired)
{
//of course.. replace ANYKNOWNVALUEHERETOCHECK with "UserId" or something you set on the login that you can check here to see if its empty.
if (Session["IsSessionValid"] == null)
{
//This means for some reason the session expired before the authentication ticket. Force a login.
FormsAuthentication.SignOut();
Response.Redirect(FormsAuthentication.LoginUrl, true);
return;
}
}
}
}
}
私は開発環境と開発統合環境でコードとすべてのものをチェックしようとしましたが、何も見つかりませんでした。上記の問題の考えられる理由を知るのを手伝ってくれる人はいますか?
よろしくお願いいたします。 サントッシュ・クマール・パトロ