Using Session with a Web Handler File (ashx)

In on of our project we use ASHX file to dynamicly generate stylesheets depending on the user. An problem occurred when the userdata was loaded from the Session. The Session object was NULL.

After searching the internet I found the solution for this problem. You need to implement the folowing interfaces on the ASHX;  IRequiresSessionState and IReadOnlySessionState. See example below.

[code:c#]

public class Style : IHttpHandler, IRequiresSessionState, IReadOnlySessionState {}

[/code]

 

Leave a Reply

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