Session is null in Generic Handler (ashx)

System.NullReferenceException (“Object reference not set to an instance of an object”) is thrown when you try to read/write the Session object in a generic handler without implementing System.Web.SessionState.IRequiresSessionState. If your intention is to read only, then use IReadOnlySessionState instead. Example: