Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET HttpModule : detect first request in a session

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?

like image 948
MSI Avatar asked Feb 27 '23 07:02

MSI


1 Answers

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.

like image 134
Nick Craver Avatar answered Mar 11 '23 04:03

Nick Craver