如果页面超时,我们如何在页面上创建新的会话

发布于 2024-10-22 02:44:36 字数 362 浏览 1 评论 0原文

如果超时,有没有办法创建新会话?使用 asp.net 进行移动应用程序开发

收到此错误:

页面需要不再可用的会话状态。会话已过期、客户端未发送有效的会话 cookie,或者会话状态历史记录大小太小。尝试增加历史记录大小或会话过期限制

这是我在 web.config 中的内容:

  <sessionState cookieless="UseCookies" cookieName="Mobile_Session" regenerateExpiredSessionId="true">
    </sessionState>

is there a way to create a new session if it has timed out ? in mobile appication developing using asp.net?

getting this error:

the page requires session state that is no longer available. either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. try increasing the history size or session expiry limit

this is what i have in my web.config:

  <sessionState cookieless="UseCookies" cookieName="Mobile_Session" regenerateExpiredSessionId="true">
    </sessionState>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

用心笑 2024-10-29 02:44:36

一旦会话过期,就无法将其恢复。您有多种选择。

  • 增加会话超时时间
    web.config 设置(使其最后
    更长)
  • 定期导致回发
    刷新会话超时(这是
    通常在隐藏的 iframe 中完成,因此用户不知道或某种弹出窗口为用户提供选项)
  • 将用户重定向到登录页面或主页并向他们解释他们的会话已过期。将最初请求的 URL 保存在新创建的会话中也很有帮助,这样他们就可以选择返回到他们所在的页面。

Once the session has expired, there's no way to get it back. You have several options.

  • Increase the session timeout in your
    web.config settings (make it last
    longer)
  • Periodically cause a postback to
    refresh the session timeout (this is
    usually done in a hidden iframe so the user doesn't know or some kind of popup to give the user the option)
  • Redirect the user to a login page or home page and explain to them that their session expired. Its also helpful to save the originally requested url in the newly created session so they have the option to return to the page they were on.
无需解释 2024-10-29 02:44:36

会话处理是在服务器上完成的,因此如果客户端在当前会话超时后发送请求,ASP.Net 应用程序将自动创建一个新会话。

据我所知,一旦会话超时,就无法重新启动它或从中恢复信息。如果您想阻止会话结束,那么您可以定期发送一个小型 AJAX 请求来阻止它(例如,如果会话在 20 分钟后结束,则每 15 分钟发送一次请求)。此请求将强制会话保持活动状态。

Session handling is done on the server so if the client sends a request after their current session has timed out the the ASP.Net application will automatically create a new session.

As far as I know once the session has timed out it is not possible to restart it or recover information from it. If you want to prevent a session from ending then you could send a small AJAX request periodically to prevent it (e.g. if you session ends after 20 minutes then send a request every 15 minutes). This request would force the session to stay active.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文