ASP.NET HttpModule:检测会话中的第一个请求

发布于 2024-09-16 18:41:44 字数 75 浏览 2 评论 0原文

我为我们的网站编写了一个 HttpModule,它通常接受请求并检查特定文件扩展名以及特定会话变量的值。是否可以检测会话中的第一个请求?

I have written a HttpModule for our site which generally accepts requests and checks for specific file extensions as well as the value of a specific session variable. Is it possible to detect the first request in a session?

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

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

发布评论

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

评论(1

薄情伤 2024-09-23 18:41:44

您可以使用 HttpSessionState 上的一个属性,称为IsNewSession,例如:

if(Context.Session != null && Context.Session.IsNewSession) {
  //do something, session was created this request
}

您只能当然,在会话状态可用后执行此操作,但从您在模块中所做的操作来看,这似乎不是问题,如果是,请发表评论。

There's a property on HttpSessionState you can use called IsNewSession, e.g.:

if(Context.Session != null && Context.Session.IsNewSession) {
  //do something, session was created this request
}

You can only do this after session state is available of course, but from what you're doing in your module, that doesn't seem to be a problem, please comment if it is.

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