ASP.NET HttpModule: Defining the First Request in a Session

I wrote an HttpModule for our site, which usually 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?

+3
source share
1 answer

Here is the HttpSessionState property , which you can use called IsNewSession , for example:

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

You can only do this after the session state is available, but from what you are doing in your module, this does not seem to be a problem, please comment if that is the case.

+8
source

Source: https://habr.com/ru/post/1762973/


All Articles