BeginRequest 每次都会触发吗?哪些 HttpApplication 事件何时触发? Ajax 有什么不同吗?

发布于 2024-09-30 11:31:35 字数 527 浏览 1 评论 0原文

我对 HttpApplication 事件有点困惑。

我有一个从 HttpModule 初始化的 SessionService*。 HttpModule 订阅 HttpApplication.BeginRequest

在模块中,我创建了一个new SessionService()

SessionService 的构造函数设置SessionService.ServiceId = Guid.NewGuid()

我正在使用 jquery 从网页上单击的链接发送两个 ajax 请求。两个链接都返回指示 SessionService.ServiceId 的 JSON,并且它相同

我不知道为什么会发生这种情况,但我最好的客人是我在事件触发时产生误解,并且其中一些事件不会触发每个 httprequest。感谢您的帮助。

*会话服务与HttpSessionState对象无关

I am a little confused about the HttpApplication events.

I have a SessionService* that is initialized from an HttpModule. The HttpModule subscribes to HttpApplication.BeginRequest.

In the module I create a new SessionService().

The constructor of the SessionService setsSessionService.ServiceId = Guid.NewGuid().

I am using jquery to send two ajax requests from a link being clicked on a webpage. Both of the links return JSON indicating the SessionService.ServiceId, and it is the same.

I don't know why this is happening, but my best guest is I am misunderstanding when the events fire, and that some of them don't fire every httprequest. Thanks for your help.

*the session service has nothing to do with the HttpSessionState object

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

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

发布评论

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

评论(1

独闯女儿国 2024-10-07 11:31:36

BeginRequest 在每个请求上触发:无论是否是 Ajax,它仍然是一个 HTTP 请求。

请注意:new Guid() 表示全零 GUID。您可能想使用Guid.NewGuid()

BeginRequest fires on every request: whether it's Ajax or not, it's still a HTTP request.

Be careful: new Guid() represents an all-zero GUID. You probably wanted to use Guid.NewGuid().

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