Csharp Web session in generic handler

In order to access Session from a for http handler you need to explicitly implement IRequiresSessionState interface.

for example

public class AGenericHandler : IHttpHandler, IRequiresSessionState
{

 

Keep in mind that if you do that there will be an implicit locking on the session object and you won’t be able to have multiple handlers in the same session state processed simultaneously.

There is an IReadOnlySessionState interface as well for read-only session state access.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.