gpt4 book ai didi

asp.net-core - HttpContext.Items 是否在 asp.net core 中的请求之间共享?

转载 作者:行者123 更新时间:2023-12-02 21:16:34 24 4
gpt4 key购买 nike

如果我将某些内容设置为HttpContext.Items["Username"] = "adam";HttpContext.Items["Username"] 对于每个请求来说都是唯一的,还是可以在请求之间重叠?

最佳答案

Are HttpContext.Items shared between requests in asp.net core?

简短回答:

引用documentation

Working with HttpContext.Items

The HttpContext abstraction provides support for a dictionary collection of type IDictionary<object, object>, called Items. This collection is available from the start of an HttpRequest and is discarded at the end of each request. You can access it by assigning a value to a keyed entry, or by requesting the value for a particular key.

引用Introduction to session and application state in ASP.NET Core

因此,项目会在每个请求结束时被丢弃,并且仅与当前请求相关。

关于asp.net-core - HttpContext.Items 是否在 asp.net core 中的请求之间共享?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46492423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com