Posts filed under 'C#'
Session State and Generic Handlers
The other day for a project I needed to read some session variables which had been set within a Generic Handler ( ashx file )… Now to my amazement through debugging I found that the Session State bag was not been populated and thus was always Null.
The solution to my problem : IRequiresSessionState. I had never come across this interface before but it was the magic key!
According to MSDN :- Specifies that the target HTTP handler requires read and write access to session-state values. This is a marker interface and has no methods.
However, if you only require readonly access then alternatively it is better to make use of IReadOnlySessionState. This will have a performance improvement and provide more scalability.
1 comment October 1, 2006