单个请求生命周期的存储介质?
我确信有一个基于请求范围的对象
的存储介质,类似于HttpContext.Current.Session
,它仅在单个请求的生命周期内全局持续存在,但我我这辈子都记不住了。
Im sure there was a request-wide object
-based storage medium, similar to HttpContext.Current.Session
, that persisted globally just for the life of a single request, but I cannot for the life of me remember it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我打赌您正在考虑 HttpContext.Items。
对于在请求周期不同部分的 HttpModule、HttpHandler 和页面之间共享状态非常有用。
更多阅读:
请注意,HttpContext.Items 适用于 ASP.NET WebForms和 ASP.NET MVC,但在同一个 Web 应用程序中使用两者时有一个警告。有关更多信息,请参阅此问题。
I bet you're thinking of HttpContext.Items.
Very useful for sharing state between HttpModules, HttpHandlers and pages from different parts of the request cycle.
More reading:
Note that HttpContext.Items works for both ASP.NET WebForms and ASP.NET MVC but it there's a caveat when using both in the same web app. More about that in this question.
ASP.Net MVC 中有 TempData 。保留在那里的物品只能在一个请求到下一个请求时才能保存下来。最终,它的存储是会话状态。
There's TempData in ASP.Net MVC. Items persisted there survive only from one request to the next. Ultimately, its storage is session state.
您不能使用
ViewData
(如果是 ASP.NET MVC)或 ViewState(如果是 ASP.NET)吗?Couldn't you use
ViewData
(if its ASP.NET MVC) or ViewState (if its ASP.NET)?