1

以下是几个月前我在博客上提出的一个问题,但我仍然没有得到正确的答案。几天前,有人问我是否有答案,所以我决定把这个问题复制到这里,让有意愿和有能力的开发人员得到更多的曝光。无论如何,这里...


我一直在开发一个 ASP.NET Web 应用程序,它利用AJAX Control Toolkit控件来扩展应用程序的可用性。此外,该应用程序是一个严肃的业务应用程序,需要安全性,包括加密、身份验证和授权。HTTP 会话是一个 InProc 模式会话,默认时间为 20 分钟。

这当然意味着,如果用户在其浏览器上离开页面超过 20 分钟,则会话已过期,并且任何发回服务器的帖子都会将浏览器重定向到登录页面。但是,例如,如果页面包含AJAX 控件工具包中的AutoCompleteExtender控件,用户可能会返回浏览器并开始使用扩展器的功能,需要后台回调,但会意识到该控件根本不工作 - 没有错误没有重定向到登录页面!?


就像我说的那样,我没有解决方案,所以我最终将SessionExpiredMonitor(由 Herr Ziffer)放在我的所有页面上(在我的 MasterPage 中),这导致每个页面在 19 分钟内自动退出,然后将浏览器重定向到登录页面。但是,我认为这不是一个解决方案,所以如果你能解决这个问题,请告诉我。非常感谢。

4

3 回答 3

1

On the server side you can detect that the session is expired and return a strong typed exception. On the browser side, you can specifically detect for that error and simply have the page refresh. This assumes that when your page posts back for the refresh that your application detects expired sessions and has them login again.

于 2008-11-02T20:15:44.623 回答
0

What's wrong with redirecting the user to the login page after his session actually expired? From a user point of view I do really prefer this over not noticing an expired session, filling out some way too long form and actually notice the expiration on submit. It's at least a very user friendly solution to the problem.

于 2008-11-02T23:37:28.833 回答
0

我认为自动重定向是更可取的解决方案,主要是出于明显的安全原因。

您可以通过在 18 分钟不活动后向用户显示警报来进一步扩展功能,警告他们他们的会话将在 1 分钟内到期,并提供一种通过单击按钮来扩展会话的方法,该按钮反过来调用后端页面以恢复活力会议。

就在会话到期并且页面将用户重定向到登录页面之前,您可以保存用户/页面/帐户的状态,以便当他们重新登录时,他们可以被重定向回他们上次查看的页面。

于 2008-11-03T17:29:05.160 回答