Tracking session size in ASP.NET applications

Is very common that you might have the need to track the size of the session of your application.

This is very common in WebMap applications. To make it super easy to do this I have create an HttpModule.

To use use first make sure that your route config has an ignore route for the handler path.
Usually the file is App_Start\RouteConfig.cs and it should contain something like:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}")

To use this module

  1. Install the nuget by running the command from the Package Manager Console
    Install-Package WebMapOnlineSessionsModule

  2. add the following elements inside the web.config

  <system.webServer>
   ...
    <modules>
      ...
      <add name="WebMapOnlineUsersModule" type="UpgradeHelpers.WebMap.Server.OnlineUsersModule" />
    </modules>
    <handlers>
       ...
<add verb="*." path="sessioninfo.axd/*" name="SessionInfo" type="UpgradeHelpers.WebMap.Server.SessionsInfoHandler, OnlineUserModule" />

      ...
    </handlers>

    ...
   </system.webServer>
  1. Run your application
  2. From another tab browse to: applicationURL\sessioninfo.axd/sessionsinfo

This will provide an information like:

If you are curious the code is available from https://github.com/orellabac/OnlineSessionModule