I would like to use the Session-per-request template, as is often done when using NHibernate in ASP.NET.
My first thought was to put the code in a context in the BeginRequest event handler in Global.asax, but I found that this event fires not only for the initial request, which actually performs this work, but also for subsequent requests for static files. such as CSS and images.
I donβt want to create a whole bunch of additional contexts when they are not needed, so is there a way I can just run my code on the initial request and not on static files?
source share