如何在 ASP.NET 3.5 中对每个 http 请求进行缓存

发布于 2024-08-31 04:35:23 字数 199 浏览 2 评论 0原文

我们使用 ASP.NET 3.5(基于控件的方法),并且只需要特定于一个 http 请求的存储。

使用会话 id 中的键的线程特定缓存将不起作用,因为线程应该被池化,因此我有机会在缓存中获得来自某些先前请求的数据,这在我的情况下是不可取的。我总是需要为整个请求中的每个请求提供全新的存储空间。

有什么想法如何在 ASP.NET 3.5 中做到这一点吗?

We using ASP.NET 3.5 (Controls-based approach) and need to have storage specific for one http request only.

Thread-specific cache with keys from session id won't work because threads are supposed to be pooled and therefore I have a chance to have data from some previous request in cache, which is undesirable in my case. I always need to have brand new storage for each request available through whole request.

Any ideas how to do it in ASP.NET 3.5?

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

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

发布评论

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

评论(3

我是有多爱你 2024-09-07 04:35:23

我们使用了 HttpContext。 Current.Items集合做RequestScope缓存。效果很好。

We have used HttpContext.Current.Items collection to do RequestScope caching. It works well.

眸中客 2024-09-07 04:35:23

使用 Context 集合怎么样?这允许在所有控件之间共享数据,但仅持续请求。

像这样使用它
context.Items("base_url") = "default.aspx"

How about using the Context collection. This allows data to be shared between all your controls but only lasts for the request.

Use it like this
context.Items("base_url") = "default.aspx"

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