ASP.NET 中的持久对象

发布于 2024-09-02 17:36:09 字数 477 浏览 2 评论 0原文

我试图找到保存对象或在代码中稍后使用同一对象的最佳方法。因此,我创建一个对象,然后您被重定向到需要使用该对象中的变量的另一个页面(表单)。该表单被提交给第三方,他们完成了一些工作,然后他们在我的应用程序上请求一个页面,该页面运行更多代码并再次需要对象变量。

  • 我想到了数据库,但这一切都是一次性完成的。这是在用户结账过程中完成的,结账结束后,没有理由再次检索该对象。因此,从数据库添加和检索似乎有点矫枉过正,我认为这会使过程变慢。
  • 现在我正在使用 Session,但我一直听说不要使用它,但没有人真正说为什么我不应该使用它,除非这是一种不好的做法。
  • 我不能真正使用回发值,因为页面不能那样工作。结帐过程从 dll 代码开始,该代码重定向到提交给第三方的表单,并且第三方请求页面。
  • 开始阅读有关 Cache 对象的内容,但我还没有使用过它,而且我还不确定它。

所以,我不太确定最好的方法。有哪些选择以及每个人都推荐的最佳方法是什么?

I'm trying to find the best way to persist an object or in use the same object at a later point in the code. So, I create an object, then you're redirected to another page(a form) that needs to use variables from that object. That form is submitted to a third party and there is stuff done on their end and then they request a page on my application that runs some more code and needs the objects variables again.

  • I thought about Database but this is all done at once. This is done during a user checkout process and after it's over, there's no reason to retrieve this object again. So adding and retrieving from a database seems like it would be overkill and I think it would make the process slower.
  • Right now I'm using Session but I keep hearing not to use that but no one is really saying why I shouldn't except it is bad practice.
  • I can't really use post back values because the pages don't work that way. The checkout process starts off in a dll code that redirects to the form that is submitted to the third party and the a page is requested by the third party.
  • Started reading about Cache object but I haven't used this yet and I am not sure about it yet.

So, I'm not really sure of the best way. What are all the options and what does everyone recommend as the best way?

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

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

发布评论

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

评论(1

云朵有点甜 2024-09-09 17:36:09

如果您使用会话,并且会话过期,您将丢失数据。用户必须重新开始。此外,所有这些数据都会一直保留到用户离开页面后 20 分钟,默认情况下

将其保留在数据库中也不错,并且该记录可以在以后为您提供有用的审计跟踪数据。

缓存对象是全局缓存,因此它不特定于任何特定用户。应用程序域中的任何用户或页面都可以访问该数据。您可以使用用户名来保留它,但我认为数据库是更好的选择

If you use Session, and the session expires, you lose the data. The user would have to start over. Also, all that data is hanging around until 20 minutes after the user leaves the page, by default

Persisting it in a database isn't bad, and the record can give you useful audit trail data later.

The cache object is a global cache, so its not specific to any particular user. Any user or page in the application domain can access that data. You could use the username to keep it, but I think the database is a better option

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