gpt4 book ai didi

c# - AuthenticateRequest 与 PostAuthenticateRequest + session

转载 作者:太空宇宙 更新时间:2023-11-03 13:22:30 24 4
gpt4 key购买 nike

我们在使用自定义控件的 AuthenticateRequest 时遇到问题:对于持久化信息,我们使用HttpContext.Current.Application.

由于各种原因,如果多个用户同时工作,这将无法正常工作,因为应用程序 key 不是决定性的。

问题:持久化发生在 AuthenticateRequest 事件中,据我所知,在该事件中无法访问 Session。我搜索了一下,发现了 PostAuthenticateRequest 事件和关于差异的描述:http://leastprivilege.com/2006/07/02/authenticaterequest-vs-postauthenticaterequest/

可悲的是,我仍然无法访问 session ,HttpApplication 抛出错误:

{"Session state is not available in this context."}

并且 HttpApplication.Context.Session 一直为 NULL。

此时是否有可能获得 session ?或者我可以使用另一个事件来达到相同的目的吗?

提前致谢。

马蒂亚斯

Edith:我发现 Header 在 MapRequestHandler (Header set) 和 PostMapRequestHandler (Header not set) 之间丢失了

最佳答案

你的问题是PostAuthenticateRequest发生在管道的较早位置,即 AcquireRequestState 之前叫做。为了访问 session 状态,您需要执行该事件,并且应该查看生命周期后期的事件。如果您不熟悉事件序列,请查看 here ...

关于c# - AuthenticateRequest 与 PostAuthenticateRequest + session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23684144/

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