mardi 23 septembre 2008

Session lost after directory addition on an ASP.net site

During the development of a site creating directories, iIdiscover that IIS lost his session on each directories modification.


Fortunatly ASP.net provide a service to store session out of your website : ASP.NET State Service.


First step is to start the service and request it to start autmtically.
Two parameters can be set in the registry : the port to use and if the service can be reach from a remote computer.


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters
By default the port is : 42424

Now the service is configured and running, the last step is to add a new section in your web.config file :



...


In this example, the session is stored in the Asp.net state server, but it's also possible to store it in a Sql server database.


Of course, each objects store in session must be serializable

Aucun commentaire: