ASP.net 会话,与 NHibernate 交互

发布于 2024-07-27 01:35:23 字数 167 浏览 4 评论 0原文

我有一个关于如何在用户访问期间保持当前 ASP.net/User 会话的问题。 保留当前 User 对象的最佳方法是什么?

目前我将它作为会话对象保留在 ASP.net 的会话管理中。 我确实有 Context.User.Identify.User 保留电子邮件地址/PK,但有更好的方法吗?

I have a question about how to keep the current ASP.net/User's session during the duration of a user's visit. What is the best way to keep the current User object?

Currently I am keeping it as a session object in the Session management in ASP.net. I do have Context.User.Identify.User keeping the email address/PK, but is there a better way to do this?

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

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

发布评论

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

评论(1

梦在深巷 2024-08-03 01:35:23

此处概述了 hibernate 会话和事务管理。

  • 构建一个单例会话工厂来负责为您提供服务
    会议。
  • 如果要遵循每个请求会话模式,请考虑将会话存储在 Context.Items 中
  • 考虑使用每个会话会话:

<块引用>

在这种情况下,单个会话的范围比单个数据库事务更大,并且它可能跨越多个数据库事务。 每个请求事件都在单个数据库事务中处理,但会话的刷新将延迟到会话和最后一个数据库事务结束,以使会话原子化。

There is an overview on hibernate session and transaction management here.

  • Build a singleton session factory to take care of serving up your
    sessions.
  • If want to follow the session-per-request pattern, consider storing the session in Context.Items
  • Consider using the session-per-conversation:

In this case a single Session has a bigger scope than a single database transaction and it might span several database transactions. Each request event is processed in a single database transaction, but flushing of the Session would be delayed until the end of the conversation and the last database transaction, to make the conversation atomic.

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